| | |
| | | @on-load="onLoad" |
| | | > |
| | | <template #menu-left> |
| | | <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleView">导出</el-button> |
| | | <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleExport">导出</el-button> |
| | | <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleView">导入</el-button> |
| | | <!-- <el-button type="primary" size="default" icon="el-icon-circle-plus" plain @click="handleAdd">新增</el-button> --> |
| | | </template> |
| | | <template #menu="scope"> |
| | | <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleEdit(scope.row, scope.index)">编辑</el-button> |
| | | <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleView(scope.row, scope.index)">删除</el-button> |
| | | <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleView(scope.row, scope.index)">产生机床回传机构树</el-button> |
| | | <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleDel(scope.row, scope.index)">删除</el-button> |
| | | <el-button type="primary" text size="default" icon="el-icon-upload" @click.stop="handleUp(scope.row, scope.index)">产生机床回传机构树</el-button> |
| | | </template> |
| | | |
| | | <template #status="{ row }"> |
| | |
| | | </template> |
| | | </avue-crud> |
| | | |
| | | <el-dialog title="编辑" append-to-body v-model="editBox" width="60%"> |
| | | <avue-form ref="editFormModal" :option="editFormModal" v-model="form" @submit="formSubmit" /> |
| | | <el-dialog :title="machineTitle" append-to-body v-model="editBox" width="60%"> |
| | | <avue-form ref="editFormModal1" :option="editFormModal" v-model="editForm" @submit="formSubmit" @resetForm="resetForm"> |
| | | <template #ownerDept="{}"> |
| | | <el-tree-select v-model="editForm.ownerDept" :data="organizationTreeList"/> |
| | | </template> |
| | | </avue-form> |
| | | </el-dialog> |
| | | </basic-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import { exportBlob } from '@/api/common'; |
| | | import { getToken } from '@/utils/auth'; |
| | | import NProgress from 'nprogress'; |
| | | import { downloadXls } from '@/utils/util'; |
| | | import 'nprogress/nprogress.css'; |
| | | export default { |
| | | data() { |
| | | var that = this; |
| | | return { |
| | | organizationTreeList: [], |
| | | machineTitle: "新增", |
| | | isAdd: true, |
| | | editBox: false, |
| | | search: { |
| | | keyword: "", |
| | |
| | | current: 1, |
| | | total: 0, |
| | | }, |
| | | editForm: {}, |
| | | option: { |
| | | index: true, |
| | | addBtn: false, |
| | |
| | | }, |
| | | { |
| | | label: '机床型号', |
| | | prop: '', |
| | | prop: 'name', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | }, |
| | | { |
| | | label: '机床类型', |
| | | prop: '', |
| | | prop: 'machineSpec', |
| | | type: 'select', |
| | | span: 12, |
| | | dicUrl: '/blade-system/dict-biz/dictionary?code=machine_group', |
| | | dicUrl: '/blade-system/dict-biz/dictionary?code=machine_spec', |
| | | props: { |
| | | label: 'dictValue', |
| | | value: 'dictKey', |
| | |
| | | }, |
| | | { |
| | | label: '所属机床组', |
| | | prop: '', |
| | | prop: 'machineGroupCode', |
| | | type: 'select', |
| | | span: 12, |
| | | dicUrl: '/blade-system/dict-biz/dictionary?code=machine_group', |
| | |
| | | }, |
| | | { |
| | | label: '操作员', |
| | | prop: '', |
| | | prop: 'operator', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | }, |
| | | { |
| | | label: '所属组织', |
| | | prop: '', |
| | | type: 'select', |
| | | span: 12, |
| | | dicUrl: '/blade-system/dict-biz/dictionary?code=machine_group', |
| | | props: { |
| | | label: 'dictValue', |
| | | value: 'dictKey', |
| | | } |
| | | prop: 'ownerDept', |
| | | span: 12 |
| | | }, |
| | | { |
| | | label: '生产商', |
| | | prop: '', |
| | | prop: 'manufacturer', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | }, |
| | | { |
| | | label: '轮询时间(小时)', |
| | | prop: '', |
| | | prop: 'pollingHours', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | }, |
| | | { |
| | | label: '系统控制', |
| | | prop: '', |
| | | prop: 'controlSystem', |
| | | type: 'select', |
| | | span: 12, |
| | | dicUrl: '/blade-system/dict-biz/dictionary?code=machine_control_system', |
| | |
| | | }, |
| | | { |
| | | label: '状态', |
| | | prop: 'checkbox', |
| | | prop: 'status', |
| | | type: 'checkbox', |
| | | span: 12, |
| | | dicData: [{ |
| | |
| | | }, |
| | | { |
| | | label: '程序下发目录', |
| | | prop: '', |
| | | prop: 'progSendDir', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | }, |
| | | { |
| | | label: '程序回传目录', |
| | | prop: '', |
| | | prop: 'progReceiveDir', |
| | | type: 'input', |
| | | span: 12, |
| | | dataType: 'string', |
| | | }, |
| | | { |
| | | label: '备注', |
| | | prop: '', |
| | | prop: 'remark', |
| | | type: 'textarea', |
| | | span: 24, |
| | | dataType: 'string', |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | handleEdit() { |
| | | handleAdd() { |
| | | this.machineTitle = "新增"; |
| | | this.isAdd = true; |
| | | this.editBox = true; |
| | | this.$refs.editFormModal1.resetForm(); |
| | | }, |
| | | formSubmit() { |
| | | |
| | | handleEdit(row,index) { |
| | | this.machineTitle = "编辑"; |
| | | this.isAdd = false; |
| | | axios({ |
| | | url: '/blade-mdm/machine/detail', |
| | | method: 'get', |
| | | params: {id: row.id}, |
| | | }).then( |
| | | res => { |
| | | res.data.data.status = [res.data.data.status]; |
| | | this.editForm = res.data.data; |
| | | this.editBox = true; |
| | | }, |
| | | error => { |
| | | this.loading = false; |
| | | } |
| | | ); |
| | | }, |
| | | handleDel(row,index) { |
| | | this.loading = true; |
| | | axios({ |
| | | url: '/blade-mdm/machine/remove', |
| | | method: 'post', |
| | | params: {ids: row.id}, |
| | | }).then( |
| | | res => { |
| | | this.loading = false; |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.onLoad(); |
| | | done(); |
| | | }, |
| | | error => { |
| | | this.loading = false; |
| | | } |
| | | ); |
| | | }, |
| | | handleUp(row,index) { |
| | | this.loading = true; |
| | | axios({ |
| | | url: '/blade-mdm/machine/gen-fileback-dirs', |
| | | method: 'post', |
| | | params: {id: row.id}, |
| | | }).then( |
| | | res => { |
| | | this.loading = false; |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.onLoad(); |
| | | done(); |
| | | }, |
| | | error => { |
| | | this.loading = false; |
| | | } |
| | | ); |
| | | }, |
| | | handleExport() { |
| | | this.$confirm('是否导出?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }).then(() => { |
| | | NProgress.start(); |
| | | exportBlob( |
| | | `/blade-mdm/machine/export?${this.website.tokenHeader}=${getToken()}` |
| | | ).then(res => { |
| | | downloadXls(res.data, `导出机床${this.$dayjs().format('YYYY-MM-DD HH:mm:ss')}.xlsx`); |
| | | NProgress.done(); |
| | | }); |
| | | }); |
| | | }, |
| | | formSubmit(params, done) { |
| | | var obj = {...params}; |
| | | if(params.status.length == 0) { |
| | | obj.status = "0"; |
| | | }else { |
| | | obj.status = "1"; |
| | | } |
| | | if(this.isAdd) { //新增 |
| | | var url = '/blade-mdm/machine/save'; |
| | | }else { |
| | | var url = '/blade-mdm/machine/update'; |
| | | } |
| | | this.loading = true; |
| | | axios({ |
| | | url: url, |
| | | method: 'post', |
| | | data: obj, |
| | | }).then( |
| | | res => { |
| | | this.loading = false; |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | this.editBox = false; |
| | | this.onLoad(); |
| | | done(); |
| | | } |
| | | ); |
| | | }, |
| | | handleView() { |
| | | |
| | |
| | | refreshChange() { |
| | | |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | onLoad() { |
| | | this.loading = true; |
| | | var obj = { |
| | | keyword: this.search.keyword, |
| | |
| | | |
| | | } |
| | | ); |
| | | }, |
| | | traversalLabelValueToTree(tree) { //遍历数组 |
| | | return tree.map(node => { |
| | | // 1. 添加 label 和 value 字段 |
| | | const newNode = { |
| | | ...node, |
| | | label: node.fullName, |
| | | value: node.id, |
| | | }; |
| | | // 2. 如果有 children,递归处理 |
| | | if (node.children && node.children.length > 0) { |
| | | newNode.children = this.traversalLabelValueToTree(node.children); |
| | | } |
| | | return newNode; |
| | | }); |
| | | } |
| | | }, |
| | | mounted() { |
| | | //判断版本 0:涉密网,1:工控网;//工控网5个,涉密网4个 |
| | | axios({url: '/blade-mdm/system/param/getValue?paramKey=networkType',method: 'get'}).then(res => { |
| | | if(res.data.data === "0") { |
| | | var aurl = "/blade-system/dept/lazy-list"; |
| | | }else { |
| | | var aurl = "/blade-mdm/system/dept/lazy-list"; |
| | | } |
| | | axios({url: aurl,method: 'get'}).then(resp => { |
| | | this.organizationTreeList = this.traversalLabelValueToTree(resp.data.data); |
| | | }) |
| | | } |
| | | ); |
| | | } |
| | | }; |
| | | </script> |
| | | |