1
lzhe
2024-11-01 e5cdf3af17609b49138cec3e8fb200752365f651
src/views/console/workstation/index.vue
@@ -7,11 +7,10 @@
                  <el-aside width="200px" v-loading="showGrouploading">
                     <el-container>
                        <el-main class="nopadding">
                           <el-tree ref="group" class="menu" node-key="id" :data="group"
                              :current-node-key="treeCheckKey" :highlight-current="true"
                              :expand-on-click-node="false" :check-on-click-node="true"
                              :default-expanded-keys="[1]" :render-content="renderContent"
                              :filter-node-method="groupFilterNode" @node-click="groupClick1"></el-tree>
                           <el-tree :expand-on-click-node="false" ref="group" class="menu" node-key="id"
                              :data="group" :current-node-key="treeCheckKey" :highlight-current="true"
                              :check-on-click-node="true" :default-expanded-keys="[1]"
                              :render-content="renderContent" @node-click="groupClick1"></el-tree>
                        </el-main>
                     </el-container>
                  </el-aside>
@@ -19,89 +18,194 @@
                     <el-header>
                        <div class="left-panel">
                           <el-button @click="table_add" type="primary" icon="el-icon-plus"></el-button>
                           <el-button type="danger" plain icon="el-icon-delete"></el-button>
                           <el-button type="danger" plain icon="el-icon-delete" @click="batchDel"></el-button>
                           <!-- <el-button type="primary" plain>导入</el-button>
                           <el-button type="primary" plain>批量操作</el-button> -->
                        </div>
                        <div class="right-panel">
                           <div class="right-panel-search">
                              <span>类型</span>
                              <el-select v-model="type" style="width: 240px">
                              <el-select v-model="type" style="width: 240px" clearable>
                                 <el-option v-for="item in types" :key="item.value" :label="item.label"
                                    :value="item.value" />
                              </el-select>
                              <span>状态</span>
                              <el-select v-model="statu" style="width: 240px">
                              <el-select v-model="statu" style="width: 240px" clearable>
                                 <el-option v-for="item in status" :key="item.value" :label="item.label"
                                    :value="item.value" />
                              </el-select>
                              <el-input v-model="keyWord" style="width: 240px" placeholder="请输入工位名称/编号" clearable></el-input>
                              <el-input v-model="keyWord" style="width: 240px" placeholder="请输入工位名称/编号"
                                 clearable></el-input>
                              <el-button @click="search" type="primary" icon="el-icon-search"></el-button>
                           </div>
                        </div>
                     </el-header>
                     <el-main class="nopadding">
                     <div style="display: flex">
                        <scTable highlight-current-row @dataChange="dataChange" @row-click="rowClick" ref="table" :params="params" :apiObj="apiObj"
                           @selection-change="selectionChange" stripe>
                           <el-table-column type="selection" width="50"></el-table-column>
                           <el-table-column label="工位编号" prop="code" width="120"
                              sortable='custom'></el-table-column>
                           <el-table-column label="工位名称" prop="name" width="120"
                              sortable='custom'></el-table-column>
                           <el-table-column label="工位类型" prop="type" width="120"
                              sortable='custom'></el-table-column>
                           <el-table-column label="工位日历" prop="calendarName" width="120"
                              sortable='custom'></el-table-column>
                           <el-table-column label="操作" fixed="right" align="right" width="160">
                              <template #default="scope">
                                 <el-button-group>
                                    <el-button text type="primary" size="small"
                                       @click="table_edit(scope.row, scope.$index)">编辑</el-button>
                                    <el-popconfirm title="确定删除吗?"
                                       @confirm="table_del(scope.row, scope.$index, '0')">
                                       <template #reference>
                                          <el-button text type="primary" size="small">删除</el-button>
                                       </template>
                                    </el-popconfirm>
                                    <el-popconfirm title="确定停用吗?"
                        <div style="display: flex">
                           <scTable highlight-current-row @dataChange="dataChange" @row-click="rowClick"
                              ref="table" :params="params" :apiObj="apiObj"
                              @selection-change="selectionChange" stripe v-show="showTable">
                              <el-table-column type="selection" width="50"></el-table-column>
                              <el-table-column label="工位编号" prop="code" width="120"></el-table-column>
                              <el-table-column label="工位名称" prop="name" width="120"></el-table-column>
                              <el-table-column label="工位类型" prop="type" width="120">
                                 <template #default="scope">
                                    <span>{{ scope.row.type == '0' ? '机器' : '人工' }}</span>
                                 </template>
                              </el-table-column>
                              <el-table-column label="工位日历" prop="calendarName" width="120"></el-table-column>
                              <el-table-column label="操作" fixed="right" align="right" width="160">
                                 <template #default="scope">
                                    <el-button-group>
                                       <el-button text type="primary" size="small"
                                          @click="table_edit(scope.row, scope.$index)">编辑</el-button>
                                       <el-popconfirm title="确定删除吗?"
                                          @confirm="table_del(scope.row, scope.$index, '0')">
                                          <template #reference>
                                             <el-button text type="primary" size="small">删除</el-button>
                                          </template>
                                       </el-popconfirm>
                                       <!-- <el-popconfirm title="确定停用吗?"
                                       @confirm="table_del(scope.row, scope.$index,'1')">
                                       <template #reference>
                                          <el-button text type="primary" size="small">停用</el-button>
                                       </template>
                                    </el-popconfirm>
                                 </el-button-group>
                              </template>
                           </el-table-column>
                        </scTable>
                        <div style="margin-left: 14px" v-if="Object.keys(previewData).length > 0">
                           <div class="header">
                              <p class="preview-title">工位信息</p>
                              <div class="preview-content">
                                 <div class="img">
                                    <img :src="machinePng" alt="">
                                    </el-popconfirm> -->
                                    </el-button-group>
                                 </template>
                              </el-table-column>
                           </scTable>
                           <div :style="{
                              'max-width': showTable ? '50%' : '100%', 'margin-left': '14px',
                              flex: '1 1 auto'
                           }" v-if="Object.keys(previewData).length > 0">
                              <div class="header">
                                 <el-icon @click="showTable = !showTable"
                                    style="font-size: 20px;cursor: pointer;margin-top: 10px;">
                                    <el-icon-arrow-left v-show="showTable" />
                                    <el-icon-arrow-right v-show="!showTable" />
                                 </el-icon>
                                 <p class="preview-title">工位信息</p>
                                 <div class="preview-content">
                                    <div class="img">
                                       <img style="width: 148px;height: 148px;" v-if="!previewData.avatar"
                                          :src="machinePng" alt="">
                                       <scUpload v-else disabled v-model="previewData.avatar" title="工位图片">
                                       </scUpload>
                                    </div>
                                    <ul>
                                       <li>工位编号 {{ previewData.code }}</li>
                                       <li>工位组 {{ previewData.groupName }}</li>
                                       <li>工位名称 {{ previewData.name }}</li>
                                       <li>工位类型 {{ types.find(v => v.value == previewData.type)?.label }}
                                       </li>
                                       <li>工位日历 {{ previewData.calendarName }}</li>
                                       <li>状态 {{ previewData.status ? '启用' : '禁用' }}</li>
                                    </ul>
                                 </div>
                                 <ul>
                                    <li>工位编号 {{previewData.code}}</li>
                                    <li>工位组 {{previewData.groupName}}</li>
                                    <li>工位名称 {{previewData.name}}</li>
                                    <li>工位类型 {{previewData.type}}</li>
                                    <li>工位日历 {{previewData.calendarName}}</li>
                                    <li>状态 {{previewData.status}}</li>
                                 </ul>
                                 <el-tabs tab-position="top" class="custom-tabs" v-model="normal">
                                    <el-tab-pane label="机器信息" name="1">
                                       <el-container>
                                          <el-header>
                                             <h2>基础数据</h2>
                                          </el-header>
                                          <el-main>
                                             <el-row>
                                                <el-col :span="4">
                                                   机器编号
                                                </el-col>
                                                <el-col :span="8">
                                                   {{ basic.machineCode }}
                                                </el-col>
                                                <el-col :span="4">
                                                   机器名称
                                                </el-col>
                                                <el-col :span="8">
                                                   {{ basic.machineName }}
                                                </el-col>
                                                <el-col :span="4">
                                                   机器品牌
                                                </el-col>
                                                <el-col :span="8">
                                                   {{ basic.machineBrand }}
                                                </el-col>
                                                <!-- <el-col :span="4">
                                                   驱动名称
                                                </el-col>
                                                <el-col :span="8">
                                                   {{ basic.typeName }}
                                                </el-col> -->
                                             </el-row>
                                          </el-main>
                                       </el-container>
                                       <el-container>
                                          <el-header style="justify-content: flex-start;">
                                             <h2>采集信息</h2>
                                             <!-- <el-button v-show="list.length > 0"
                                                @click="() => { editFlag = !editFlag; showTable = !editFlag }"
                                                style="margin-left: auto;" text type="primary"
                                                size="small">{{ editFlag ? '取消' : '配置工位采集'
                                                }}</el-button>
                                             <el-button v-show="editFlag" @click="saveInfo" text
                                                type="primary" size="small">保存</el-button> -->
                                             <!-- <el-button text type="primary" size="small"
                                                @click="editDMP">修改DMP配置</el-button> -->
                                             <el-button @click="getExport" style="margin-left: 12px" text
                                                type="primary" size="small">导出</el-button>
                                             <el-button @click="editCollection" text type="primary"
                                                style="margin-left: 0px;" size="small">数据点编辑</el-button>
                                          </el-header>
                                          <el-main>
                                             <!-- <el-table :data="list" height="200px">
                                             </el-table> -->
                                             <CollTable ref="collTable" :info="previewData"></CollTable>
                                          </el-main>
                                       </el-container>
                                    </el-tab-pane>
                                    <el-tab-pane label="扩展信息" name="2">
                                       <el-row>
                                          <el-col :span="4">
                                             工种
                                          </el-col>
                                          <el-col :span="8">
                                             {{ info.deviceType }}
                                          </el-col>
                                          <el-col :span="4">
                                             加工属性
                                          </el-col>
                                          <el-col :span="8">
                                             {{ info.properties }}
                                          </el-col>
                                          <el-col :span="4">
                                             程序传输方式
                                          </el-col>
                                          <el-col :span="8">
                                             {{ info.transmissionMode }}
                                          </el-col>
                                          <el-col :span="4">
                                             FTP目录
                                          </el-col>
                                          <el-col :span="8">
                                             {{ info.ftpCatalogue }}
                                          </el-col>
                                          <el-col :span="4">
                                             工作台
                                          </el-col>
                                          <el-col :span="8">
                                             <ul class="workbench">
                                                <li v-for="item in workbenchVOList" :key="item.sort">
                                                   {{ `【${item.sort}】` }}{{ item.name }}
                                                </li>
                                             </ul>
                                          </el-col>
                                       </el-row>
                                    </el-tab-pane>
                                 </el-tabs>
                              </div>
                              <el-tabs tab-position="top" class="custom-tabs" v-model="normal">
                                 <el-tab-pane label="机器信息" name="1">
                                    机器信息
                                 </el-tab-pane>
                                 <el-tab-pane label="扩展信息" name="2">
                                    扩展信息
                                 </el-tab-pane>
                              </el-tabs>
                           </div>
                        </div>
                     </div>
                     </el-main>
                  </el-container>
               </el-container>
@@ -111,12 +215,12 @@
               <el-container>
                  <el-aside width="200px" v-loading="showGrouploading">
                     <el-container>
                        <el-main class="nopadding">
                        <el-main class="nopadding" style="overflow: hidden;">
                           <el-tree ref="group" class="menu" node-key="id" :data="group"
                              :current-node-key="treeCheckKey" :highlight-current="true"
                              :expand-on-click-node="false" :check-on-click-node="true"
                              :default-expanded-keys="[1]" :render-content="renderContent"
                              :filter-node-method="groupFilterNode" @node-click="groupClick"></el-tree>
                              @node-click="groupClick"></el-tree>
                        </el-main>
                     </el-container>
                  </el-aside>
@@ -170,9 +274,16 @@
                     <el-header v-show="!addGroupShow">
                        <div class="left-panel">
                           <el-button @click="addChild" type="primary" plain>新增下级</el-button>
                           <el-button @click="deleteWorkGroup"
                           <el-popconfirm width="220" cancel-button-text="取消" confirm-button-text="删除"
                              title="删除会将工位组下的工位移动到默认组中,请确认是否删除?" @confirm="deleteWorkGroup">
                              <template #reference>
                                 <el-button v-show="!['1', '101'].includes(treeCheckedNode.id)" type="danger"
                                    plain>删除</el-button>
                              </template>
                           </el-popconfirm>
                           <!-- <el-button @click="deleteWorkGroup"
                              v-show="!['1', '101'].includes(treeCheckedNode.id)" type="danger"
                              plain>删除</el-button>
                              plain>删除</el-button> -->
                        </div>
                     </el-header>
                     <el-main class="" v-show="!addGroupShow">
@@ -237,21 +348,27 @@
         </el-tabs>
      </el-card>
      <Dialog ref="dialog" :option="{types,status,group}"></Dialog>
      <Dialog ref="dialog" @success="success" :option="{ types, status, group }"></Dialog>
      <CollDialog ref="CollDialog" @success="successColl" :option="{ previewData }"></CollDialog>
   </el-main>
</template>
<script>
import pmsPng from '@/assets/pms.png'
import Dialog from './Dialog.vue'
import machinePng from '@/assets/machine.png'
import CollDialog from './CollDialog.vue'
import CollTable from './CollTable.vue'
import machinePng from '@/assets/machine1.jpg'
export default {
   name: 'system',
   components: {
      Dialog
      Dialog,
      CollDialog,
      CollTable
   },
   data() {
      return {
         showTable: true,
         machinePng,
         showGrouploading: false,
         options: [],
@@ -263,29 +380,25 @@
         params: {},
         keyWord: '',
         type: '',
         statu: '1',
         statu: 1,
         types: [
            {
               label: '所有',
               value: ''
            },
            {
               label: '机器',
               value: '0'
               value: 0
            },
            {
               label: '人工',
               value: '1'
               value: 1
            },
         ],
         status: [
            {
               label: '启用',
               value: '1'
               value: 1
            },
            {
               label: '停用',
               value: '0'
               value: 0
            }
         ],
         previewData: {},
@@ -305,7 +418,25 @@
         treeCheckKey: [],
         beltline_type: [],
         group_tag: [],
         addGroupShow: false
         dmp_data_type: [],
         workstation_param_type: [],
         addGroupShow: false,
         selection: [],
         list: [],
         basic: {
            machineCode: '-',
            machineName: '-',
            machineBrand: '-',
            typeName: '-',
         },
         info: {
            deviceType: '-',
            properties: '-',
            transmissionMode: '-',
            ftpCatalogue: '-',
         },
         workbenchVOList: [],
         editFlag: false
      }
   },
   watch: {
@@ -313,7 +444,6 @@
         handler(val) {
            this.queryList().then(() => {
               if (val == 1) {
                  console.log('>>>>>>>>>>>>>>', this.treeCheckedNode)
                  this.apiObj = this.$API.workstation.getList
                  this.params = {
                     groupId: this.treeCheckedNode.id,
@@ -342,6 +472,46 @@
      this.queryList()
   },
   methods: {
      // 数据点导出
      getExport() {
         this.$HTTP.get(`/api/smis/workstation/export-dp?` + this.$TOOL.qsStringify({
            workstationId: this.previewData.id
         })).then(res => {
            if (res.code == 200) {
               window.open(res.data.link)
            }
         })
      },
      // 数据点编辑
      editCollection() {
         this.$refs.CollDialog.open('edit', this.previewData)
      },
      successColl() {
         this.$refs.collTable.refresh()
      },
      handleSelectionChange(val) {
         val.forEach(v => {
            v.bigScreen = true
            v.realTimeData = true
            v.processParameter = true
         })
         this.list.forEach(v => {
            if (val.filter(item => v.id === item.id).length == 0) {
               v.bigScreen = false
               v.realTimeData = false
               v.processParameter = false
            }
         })
      },
      editDMP() {
         this.$HTTP.get(`/api/blade-system/param/detail?paramKey=system.dmp.url`).then(res => {
            if (res.success) {
               window.open(res.data.paramValue)
            } else {
               this.$message.error(res.msg)
            }
         })
      },
      renderContent(h, { data }) {
         let img = data.groupTag == 'fms_beltline'
         return h('span', {
@@ -359,7 +529,16 @@
         this.$API.system.dic.getDic.get({ code: 'group_tag' }).then(res => {
            this.group_tag = res.data
         })
         this.$API.system.dic.getDic.get({ code: 'dmp_data_type' }).then(res => {
            this.dmp_data_type = res.data
         })
         this.$API.system.dic.getDic.get({ code: 'workstation_param_type' }).then(res => {
            this.workstation_param_type = res.data
         })
      },
      success() {
         this.search()
      },
      async queryList(flag) {
         this.showGrouploading = true
@@ -372,13 +551,15 @@
               this.showGrouploading = false
               // this.$nextTick(() => {
               if (!flag) {
                  debugger
                  let parent = res.data.filter(item => item.parentId == 0)[0]
                  this.treeCheckedNode = parent
                  this.treeCheckKey = parent.id
               } else {
                  let parent = res.data.filter(item => item.id == this.treeCheckedNode.id)[0]
                  this.treeCheckedNode = parent
                  this.treeCheckKey = parent.id
                  debugger
                  let parent = res.data.filter(item => item.parentId == 0)[0]
                  parent && (this.treeCheckedNode = parent)
                  parent && (this.treeCheckKey = parent.id)
               }
               // })
@@ -420,13 +601,11 @@
               groupCategory: this.treeCheckedNode.groupCategory
            }, this.form)
            return this.$API.workstation.saveWorkstationGroup.post(data).then(res => {
               console.log(res)
               this.queryList(true)
            })
         }
         let data = Object.assign({}, this.treeCheckedNode, this.form)
         this.$API.workstation.saveWorkstationGroup.put(data).then(res => {
            console.log(res)
            this.queryList(true)
         })
      },
@@ -441,21 +620,46 @@
         this.addGroupShow = true
         this.$refs.dialogForm.resetFields()
      },
      groupFilterNode() {
      },
      groupClick(node) {
         this.treeCheckedNode = node
      },
      search () {
      search() {
         this.groupClick1(this.treeCheckedNode)
      },
      rowClick (data) {
      rowClick(data) {
         this.previewData = data
         console.log(data)
         if (!data.id) {
            Object.keys(this.basic).forEach(key => {
               this.basic[key] = '-'
            })
            Object.keys(this.info).forEach(key => {
               this.info[key] = '-'
            })
            this.list = []
            this.workbenchVOList = []
            return
         }
         console.log(data, '>>>>>>>>>>>')
         data.machineId && this.$HTTP.get(`/api/smis/workstation/listDmpVariablesByMachineId?machineId=${data.machineId}`).then(res => {
            this.list = res?.data
            // Object.keys(this.basic).forEach(key => {
            //    this.basic[key] = res?.data?.[key] || '-'
            // })
         })
         this.$HTTP.get(`/api/smis/workstation/listDmpVariablesByWorkstationId?workstationId=${data.id}`).then(res => {
            // this.list = res?.data?.dmpVariablesVOList
            Object.keys(this.basic).forEach(key => {
               this.basic[key] = res?.data?.[key] || '-'
            })
         })
         this.$HTTP.get(`/api/smis/workstation-workbench/listWorkbench?workstationId=${data.id}`).then(res => {
            Object.keys(this.info).forEach(key => {
               this.info[key] = res?.data?.[key] || '-'
            })
            this.workbenchVOList = res?.data?.workstationList || []
         })
      },
      groupClick1(data) {
         console.log('-------', data)
         var params = {
            groupId: data.id,
            keyWord: this.keyWord,
@@ -465,29 +669,41 @@
         this.$refs.table.reload(params)
      },
      dataChange (res,data) {
      dataChange(res, data) {
         if (data.length > 0) {
            console.log(data[0], '>>>>>>>>')
            this.$refs.table.setCurrentRow(data[0])
            this.previewData = data[0]
         }else  {
            this.rowClick(data[0])
         } else {
            this.$refs.table.setCurrentRow()
            this.previewData = {}
            this.rowClick({})
         }
      },
      table_add() {
         this.$refs.dialog.open()
      },
      table_edit(row) {
         this.$refs.dialog.open('edit',row)
         this.$refs.dialog.open('edit', row)
      },
      table_del(row, index,type) {
         this.$API.workstation.deleteWork.delete({
            type,
            workstationIds:row.id
         }).then(() => {
      table_del(row, index, type) {
         this.$HTTP.delete(`/api/smis/workstation?type=0&workstationIds=${row.id}`).then(res => {
            this.search()
         })
      },
      selectionChange(selection) {
         this.selection = selection
      },
      batchDel() {
         this.$HTTP.delete(`/api/smis/workstation?type=0&workstationIds=${this.selection.map(item => item.id).join(',')}`).then(res => {
            this.search()
         })
      },
      saveInfo() {
         this.$HTTP.post('/api/smis/workstation-wcs/save', this.workbenchVOList).then(res => {
            this.editFlag = false
            this.showTable = true
         })
      },
   }
@@ -499,22 +715,27 @@
   list-style: none;
   font-size: 14px;
}
.preview-title {
   padding: 12px;
   margin-bottom: 14px;
   font-size: 16px;
}
.preview-content {
   font-size: 14px;
   display: flex;
   align-items: center;
   .img {
      width: 30%;
   }
   ul {
      list-style: none;
      display: flex;
      flex-wrap: wrap;
      li {
         width: 50%;
         flex: 1 0 auto;
@@ -522,4 +743,8 @@
      }
   }
}
.workbench {
   list-style: none;
}
</style>