new file: src/api/equipment/metering.js
new file: src/views/equipment/metering/index.vue
new file: src/views/equipment/metering/metering-form.vue
¶Ô±ÈÐÂÎļþ |
| | |
| | | import request from '@/router/axios' |
| | | |
| | | export function fetchList(query) { |
| | | return request({ |
| | | url: '/mes/equipmentDevice/page', |
| | | method: 'get', |
| | | params: query |
| | | }) |
| | | } |
| | | |
| | | export function pullEquip() { |
| | | return request({ |
| | | url: '/mes/equipmentDevice/updateDevicd', |
| | | method: 'post', |
| | | }) |
| | | } |
| | | |
| | | export function addObj(obj) { |
| | | return request({ |
| | | url: '/mes/equipmentDevice/addDevicd', |
| | | method: 'post', |
| | | data: obj |
| | | }) |
| | | } |
| | | |
| | | export function getObj(id) { |
| | | return request({ |
| | | url: '/mes/equipmentDevice/' + id, |
| | | method: 'get' |
| | | }) |
| | | } |
| | | |
| | | export function delObj(id) { |
| | | return request({ |
| | | url: '/mes/equipmentDevice/' + id, |
| | | method: 'delete' |
| | | }) |
| | | } |
| | | |
| | | export function putObj(obj) { |
| | | return request({ |
| | | url: '/mes/equipmentDevice/updateDevicd', |
| | | method: 'post', |
| | | data: obj |
| | | }) |
| | | } |
| | | |
| | | export function getEquipmentPageByWorkstation(id) { |
| | | return request({ |
| | | url: '/mes/equipmentDevice/page/' + id, |
| | | method: 'get' |
| | | }) |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="mod-config"> |
| | | <basic-container> |
| | | <ttable |
| | | :table="table" |
| | | @handleSelectionChange="handleSelectionChange" |
| | | :uploadInfo="uploadInfo" |
| | | :prelang="prelang" |
| | | :options="options" |
| | | :ajaxFun="ajaxFun" |
| | | ref="equipmentTable" |
| | | > |
| | | <template #toolbar></template> |
| | | </ttable> |
| | | <!-- å¼¹çª, æ°å¢ / ä¿®æ¹ --> |
| | | <table-form |
| | | v-if="addOrUpdateVisible" |
| | | ref="addOrUpdate" |
| | | @refreshDataList="getData" |
| | | ></table-form> |
| | | </basic-container> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { delObj, fetchList,pullEquip } from '@/api/equipment/metering' |
| | | import TableForm from './metering-form' |
| | | import ttable from '@/views/common/ztt-table.vue' |
| | | import { mapGetters } from 'vuex' |
| | | import * as fecha from 'element-ui/lib/utils/date' |
| | | import { remote } from '../../../api/admin/dict' |
| | | export default { |
| | | data() { |
| | | return { |
| | | ajaxFun: fetchList, |
| | | multipleSelection: [], |
| | | uploadInfo: { |
| | | // æ¯å¦å±ç¤ºä¸ä¼ EXCEL以å对åºçurl |
| | | isShow: true, |
| | | url: '/mes/equipment/upload' |
| | | }, |
| | | prelang: 'workstation', |
| | | options: { |
| | | height: 300, // é»è®¤é«åº¦-为äºè¡¨å¤´åºå® |
| | | stripe: true, // æ¯å¦ä¸ºæé©¬çº¹ table |
| | | highlightCurrentRow: false, // æ¯å¦è¦é«äº®å½åè¡ |
| | | border: true, // æ¯å¦æçºµåè¾¹æ¡ |
| | | lazy: false, // æ¯å¦éè¦æå è½½ |
| | | fit: true, // åç宽度æ¯å¦èªæå¼ |
| | | multiSelect: true, // |
| | | seqNo: true, |
| | | isRefresh: true, // æ¯å¦æ¾ç¤ºå·æ°æé® |
| | | isShowHide: true, // æ¯å¦æ¾ç¤ºæ¾å½±æé® |
| | | isSearch: false, // é«çº§æ¥è¯¢æé® |
| | | defaultOrderBy: { column: 'manufactureDate', direction: 'desc' } |
| | | }, |
| | | table: { |
| | | total: 0, |
| | | currentPage: 1, |
| | | pageSize: 20, |
| | | data: [], |
| | | // æ é¢ |
| | | column: [ |
| | | // 设å¤ç¼å· |
| | | { |
| | | minWidth: '30', |
| | | prop: 'code', |
| | | label: '设å¤ç¼å·', |
| | | sort: true, |
| | | isTrue: true, |
| | | formatter: (row, column, cellValue) => { |
| | | return cellValue |
| | | }, |
| | | isSearch: true, |
| | | searchInfoType: 'text' |
| | | }, |
| | | // 设å¤åç§° |
| | | { |
| | | minWidth: '30', |
| | | prop: 'name', |
| | | label: '设å¤åç§°', |
| | | sort: true, |
| | | isTrue: true, |
| | | isSearch: true, |
| | | searchInfoType: 'text' |
| | | }, |
| | | // å·¥å |
| | | // { |
| | | // minWidth: '30', |
| | | // prop: 'factoryName', |
| | | // label: 'å·¥å', |
| | | // sort: true, |
| | | // isTrue: true, |
| | | // isSearch: true, |
| | | // searchInfoType: 'text' |
| | | // }, |
| | | { |
| | | minWidth: '30', |
| | | prop: 'type', |
| | | label: '设å¤ç±»å', |
| | | // sort: true, |
| | | isTrue: true, |
| | | isSearch: true, |
| | | // searchInfoType: 'select', |
| | | formatter: this.workShopFormatter, |
| | | // optList: () => { |
| | | // return this.workshopList |
| | | // } |
| | | }, |
| | | // åå·è§æ ¼ |
| | | { |
| | | minWidth: '30', |
| | | prop: 'supplier', |
| | | label: 'åå®¶', |
| | | sort: true, |
| | | isTrue: true, |
| | | isSearch: false, |
| | | searchInfoType: 'text' |
| | | }, |
| | | // ç¶æ |
| | | { |
| | | minWidth: '30', |
| | | prop: 'status', |
| | | label: 'ç¶æ', |
| | | sort: true, |
| | | isTrue: true, |
| | | isSearch: true, |
| | | searchInfoType: 'text' |
| | | }, |
| | | // å¶é æ¥æ |
| | | { |
| | | minWidth: '150', |
| | | width: '250', |
| | | prop: 'createTime', |
| | | label: 'å建æ¶é´', |
| | | sort: true, |
| | | isTrue: true, |
| | | formatter: this.formatReceiveTime, |
| | | isSearch: true, |
| | | searchInfoType: 'datetime' |
| | | }, |
| | | |
| | | { |
| | | minWidth: '150', |
| | | width: '250', |
| | | prop: 'updateTime', |
| | | label: 'ä¿®æ¹æ¶é´', |
| | | sort: true, |
| | | isTrue: true, |
| | | formatter: this.formatReceiveTime, |
| | | isSearch: true, |
| | | searchInfoType: 'datetime' |
| | | }, |
| | | ], |
| | | toolbar: [ |
| | | { |
| | | text: 'æ°å¢', |
| | | type: 'primary', |
| | | fun: this.addOrUpdateHandle |
| | | }, |
| | | // { |
| | | // text: '忥', |
| | | // type: 'primary', |
| | | // loading: false, |
| | | // fun: this.pullEquipFun |
| | | // } |
| | | ], |
| | | operator: [ |
| | | { |
| | | text: 'ä¿®æ¹', |
| | | icon: 'el-icon-edit', |
| | | type: 'text', |
| | | size: 'small', |
| | | fun: this.addOrUpdateHandle |
| | | }, |
| | | { |
| | | text: 'å é¤', |
| | | icon: 'el-icon-delete', |
| | | type: 'text', |
| | | size: 'small', |
| | | fun: this.deleteHandle |
| | | } |
| | | ], |
| | | operatorConfig: { |
| | | fixed: 'right', |
| | | label: 'æä½', |
| | | width: 130, |
| | | minWidth: 130 |
| | | } |
| | | }, |
| | | addOrUpdateVisible: false, |
| | | workshopList: [] |
| | | } |
| | | }, |
| | | components: { |
| | | ttable, |
| | | TableForm |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['permissions']) |
| | | }, |
| | | created() { |
| | | remote('work_shop').then((response) => { |
| | | if (response.data.code === 0) { |
| | | this.workshopList = response.data.data |
| | | } else { |
| | | this.workshopList = [] |
| | | } |
| | | }) |
| | | }, |
| | | methods: { |
| | | pullEquipFun(){ |
| | | this.table.toolbar.find((e) => e.text === '忥').loading = true |
| | | pullEquip().then(res=>{ |
| | | this.$message.success(res.data.data.msg) |
| | | this.table.toolbar.find((e) => e.text === '忥').loading = false |
| | | }).catch(error=>{ |
| | | this.$message.error("åæ¥å¤±è´¥",error) |
| | | this.getData() |
| | | this.table.toolbar.find((e) => e.text === '忥').loading = false |
| | | }) |
| | | }, |
| | | workShopFormatter(row, column, cellValue) { |
| | | if(cellValue==='åæææ£éª'){ |
| | | cellValue=="åæææ£éª" |
| | | } |
| | | if(cellValue==='è¿ç¨æ£éª'){ |
| | | cellValue=="è¿ç¨æ£éª" |
| | | } |
| | | return cellValue |
| | | }, |
| | | // è·åæ°æ®å表 |
| | | getData() { |
| | | this.$refs.equipmentTable.getDataList() |
| | | }, |
| | | formatReceiveTime(row, column, cellValue) { |
| | | return cellValue ? fecha.format(new Date(cellValue), 'yyyy-MM-dd HH:mm:ss') : '' |
| | | }, |
| | | handleSelectionChange(val) { |
| | | this.multipleSelection = val |
| | | }, |
| | | // æ°å¢ / ä¿®æ¹ |
| | | addOrUpdateHandle(row) { |
| | | this.addOrUpdateVisible = true |
| | | this.$nextTick(() => { |
| | | this.$refs.addOrUpdate.init(row == null ? null : row.id) |
| | | }) |
| | | }, |
| | | // å é¤ |
| | | deleteHandle(row) { |
| | | this.$confirm('æ¯å¦ç¡®è®¤å é¤è®¾å¤å称为' + row.name, 'æç¤º', { |
| | | confirmButtonText: 'ç¡®å®', |
| | | cancelButtonText: 'åæ¶', |
| | | closeOnClickModal: false, |
| | | type: 'warning' |
| | | }) |
| | | .then(function() { |
| | | return delObj(row.id) |
| | | }) |
| | | .then((data) => { |
| | | this.$message.success('å 餿å') |
| | | this.getData() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-dialog |
| | | :title="!dataForm.id ? 'æ°å¢' : 'ä¿®æ¹'" |
| | | :close-on-click-modal="false" |
| | | :visible.sync="visible" |
| | | > |
| | | <el-form |
| | | :model="dataForm" |
| | | :rules="dataRule" |
| | | ref="dataForm" |
| | | label-width="80px" |
| | | class="l-mes" |
| | | > |
| | | <el-row> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ç¼å·" prop="code"> |
| | | <el-input v-model="dataForm.code" placeholder="ç¼å·"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="åç§°" prop="name"> |
| | | <el-input v-model="dataForm.name" placeholder="åç§°"></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ç±»å" prop="type"> |
| | | <el-select |
| | | v-model="dataForm.type" |
| | | filterable |
| | | placeholder="è¯·éæ©" |
| | | style="width:100%" |
| | | > |
| | | <el-option |
| | | v-for="item in workshopList" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="åå®¶" prop="supplier"> |
| | | <el-input |
| | | v-model="dataForm.supplier" |
| | | placeholder="åå®¶" |
| | | ></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="ç¶æ" prop="state"> |
| | | <el-select |
| | | v-model="dataForm.status" |
| | | placeholder="ç¶æ" |
| | | filterable |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="item in equipmentState" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.label" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="visible = false">åæ¶</el-button> |
| | | <el-button |
| | | type="primary" |
| | | :disabled="isSubmit" |
| | | v-thinclick="`dataFormSubmit`" |
| | | >ç¡®å®</el-button |
| | | > |
| | | </span> |
| | | </el-dialog> |
| | | </template> |
| | | <script> |
| | | import { getObj, addObj, putObj } from '@/api/equipment/metering' |
| | | import { loadFactoryList } from '@/api/basic/factory' |
| | | import { remote } from '../../../api/admin/dict' |
| | | export default { |
| | | data() { |
| | | return { |
| | | // options: regionData, |
| | | visible: false, |
| | | dataForm: { |
| | | id: 0, |
| | | number: '', |
| | | name: '', |
| | | factoryId: '', |
| | | workshop: '', |
| | | position: '', |
| | | email: '', |
| | | supplier: '', |
| | | manufacturer: '', |
| | | typeSpecification: '', |
| | | manufactureDate: '', |
| | | installDate: '', |
| | | state: '', |
| | | description: '', |
| | | value1: '', |
| | | code: null, |
| | | type: null, |
| | | status: null, |
| | | supplier: null |
| | | }, |
| | | dataRule: { |
| | | number: [{ required: true, message: 'ç¼å·ä¸è½ä¸ºç©º', trigger: 'blur' }], |
| | | name: [{ required: true, message: 'åç§°ä¸è½ä¸ºç©º', trigger: 'blur' }] |
| | | }, |
| | | factoryOptions: [], |
| | | equipmentState: [], |
| | | isSubmit: false, |
| | | workshopList: [{ |
| | | label: "åæææ£éª", |
| | | value: 'åæææ£éª' |
| | | },{ |
| | | label: 'è¿ç¨æ£éª', |
| | | value: 'è¿ç¨æ£éª' |
| | | }] |
| | | } |
| | | }, |
| | | methods: { |
| | | init(id) { |
| | | this.dataForm.id = id || 0 |
| | | this.visible = true |
| | | this.$nextTick(() => { |
| | | this.$refs.dataForm.resetFields() |
| | | if (this.dataForm.id) { |
| | | getObj(this.dataForm.id).then((response) => { |
| | | this.dataForm = response.data.data |
| | | }) |
| | | } else { |
| | | if (this.factoryOptions.length > 0) { |
| | | this.dataForm.factoryId = this.factoryOptions[0].id |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | // 表åæäº¤ |
| | | getEquipmentState() { |
| | | remote('equipment_state').then((response) => { |
| | | if (response.data.code === 0) { |
| | | this.equipmentState = response.data.data |
| | | } |
| | | }) |
| | | }, |
| | | dataFormSubmit() { |
| | | this.isSubmit = true |
| | | this.$refs.dataForm.validate((valid) => { |
| | | if (valid) { |
| | | if (this.dataForm.id) { |
| | | putObj(this.dataForm).then((data) => { |
| | | this.$message.success('ä¿®æ¹æå') |
| | | this.visible = false |
| | | this.isSubmit = false |
| | | this.$emit('refreshDataList') |
| | | }) |
| | | } else { |
| | | addObj(this.dataForm).then((data) => { |
| | | this.$message.success('æ·»å æå') |
| | | this.visible = false |
| | | this.isSubmit = false |
| | | this.$emit('refreshDataList') |
| | | }) |
| | | } |
| | | } else { |
| | | this.isSubmit = false |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | initFactorySelect() { |
| | | loadFactoryList().then((res) => { |
| | | this.factoryOptions = res.data |
| | | if (this.factoryOptions.length > 0) { |
| | | this.dataForm.factoryId = this.factoryOptions[0].id |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | created() { |
| | | this.initFactorySelect() |
| | | this.getEquipmentState() |
| | | |
| | | // remote('work_shop').then((response) => { |
| | | // if (response.data.code === 0) { |
| | | // this.workshopList = response.data.data |
| | | // } else { |
| | | // this.workshopList = [] |
| | | // } |
| | | // }) |
| | | } |
| | | } |
| | | </script> |
| | | |