¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- |
| | | * @Date: 2024-04-01 20:28:18 |
| | | * @LastEditors: gaoshp |
| | | * @LastEditTime: 2024-04-01 21:50:06 |
| | | * @FilePath: /cps-web/src/views/console/basic-data/working-condition/index.vue |
| | | --> |
| | | <template> |
| | | <el-container> |
| | | <el-header style="justify-content:flex-start"> |
| | | <el-button @click="table_add" type="primary" icon="el-icon-plus"></el-button> |
| | | <el-button type="danger" plain icon="el-icon-delete" @click="batchDel"></el-button> |
| | | </el-header> |
| | | <el-main> |
| | | <el-table v-bind="$attrs" :data="tableData" :row-key="rowKey" :border="true" :stripe="true" |
| | | @selection-change="selectionChange"> |
| | | <el-table-column type="selection" /> |
| | | <el-table-column prop="dataItem" label="å·¥ä½åéåç§°" /> |
| | | <el-table-column prop="dataTypeDesc" label="æ°æ®æ ç¾" /> |
| | | <el-table-column prop="usageName" label="è®¡ç®æ¹æ³" /> |
| | | <el-table-column prop="collectSettingItem" label="ééåéåç§°" /> |
| | | <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-button-group> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-main> |
| | | <el-drawer v-model="drawer" title="æ°å»º" :before-close="handleClose"> |
| | | <el-form :model="form" :rules="rules" :disabled="mode == 'show'" ref="dialogForm" label-width="120px" |
| | | label-position="center"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="å·¥ä½åéåç§°" prop="dataItem"> |
| | | <el-input style="width: 240px" v-model="form.dataItem" placeholder="å·¥ä½åéåç§°" |
| | | clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="æ°æ®æ ç¾" prop="usageId"> |
| | | <el-select v-model="form.usageId" clearable placeholder="æ°æ®æ ç¾" style="width: 240px"> |
| | | <el-option v-for="item in workstation_param_type" :key="item.id" :label="item.usageName" |
| | | :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="ééåéåç§°" prop="collectSettingItem"> |
| | | <el-input style="width: 240px" v-model="form.collectSettingItem" placeholder="ééåéåç§°" |
| | | clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <div style="flex: auto"> |
| | | <el-button @click="cancelClick">cancel</el-button> |
| | | <el-button type="primary" @click="confirmClick">confirm</el-button> |
| | | </div> |
| | | </template> |
| | | </el-drawer> |
| | | |
| | | </el-container> |
| | | </template> |
| | | |
| | | <script> |
| | | import config from "@/config/table"; |
| | | export default { |
| | | data() { |
| | | return { |
| | | config, |
| | | tableData: [], |
| | | workstation_param_type: [], |
| | | drawer: false, |
| | | form: { |
| | | dataItem: '', |
| | | usageId: '', |
| | | collectSettingItem: '' |
| | | }, |
| | | rules: { |
| | | dataItem: [ |
| | | { required: true, message: '请è¾å
¥å·¥ä½åéåç§°' } |
| | | ], |
| | | usageId: [ |
| | | { required: true, message: 'è¯·éæ©æ°æ®æ ç¾' } |
| | | ], |
| | | collectSettingItem: [ |
| | | { required: true, message: '请è¾å
¥ééåéåç§°' } |
| | | ], |
| | | }, |
| | | selection: [] |
| | | } |
| | | }, |
| | | created() { |
| | | this.init() |
| | | }, |
| | | methods: { |
| | | init() { |
| | | |
| | | this.$API.workingCondition.getwcsUsageList.get().then(res => { |
| | | this.workstation_param_type = res.data |
| | | }) |
| | | this.$API.workingCondition.getList.get().then(res => { |
| | | if (res.code == 200) { |
| | | this.tableData = res.data |
| | | } |
| | | }) |
| | | }, |
| | | batchDel() { |
| | | console.log(this.selection) |
| | | this.$API.workingCondition.del.post( |
| | | {}, this.selection.map(v => v.id) |
| | | ).then(res => { |
| | | this.drawer = false |
| | | this.init() |
| | | }) |
| | | }, |
| | | selectionChange(selection) { |
| | | this.selection = selection |
| | | }, |
| | | table_add() { |
| | | this.row = {} |
| | | this.drawer = true |
| | | this.$nextTick(() => { |
| | | this.$refs.dialogForm.resetFields() |
| | | }) |
| | | }, |
| | | table_edit(row) { |
| | | this.row = row |
| | | this.form.dataItem = row.dataItem |
| | | this.form.usageId = row.usageId |
| | | this.form.collectSettingItem = row.collectSettingItem |
| | | this.drawer = true |
| | | }, |
| | | table_del(row) { |
| | | this.$API.workingCondition.del.post( |
| | | {}, [row.id] |
| | | ).then(res => { |
| | | this.drawer = false |
| | | this.init() |
| | | }) |
| | | }, |
| | | cancelClick() { |
| | | this.drawer = false |
| | | }, |
| | | confirmClick() { |
| | | let { collectType: dataType } = this.workstation_param_type.find(v => v.id === this.form.usageId) |
| | | this.$refs.dialogForm.validate().then(res => { |
| | | if (res) { |
| | | if (!this.row.id) { |
| | | this.$API.workingCondition.save.post([ |
| | | { |
| | | ...this.form, |
| | | dataType |
| | | } |
| | | ]).then(res => { |
| | | this.drawer = false |
| | | this.init() |
| | | }) |
| | | } else { |
| | | this.$API.workingCondition.update.post( |
| | | { |
| | | ...this.row, |
| | | ...this.form, |
| | | dataType |
| | | } |
| | | ).then(res => { |
| | | this.drawer = false |
| | | this.init() |
| | | }) |
| | | } |
| | | |
| | | } |
| | | }) |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped></style> |