From a8230f1ab02069431738bd72f36ab95a0ace01ae Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期二, 06 八月 2024 15:22:22 +0800
Subject: [PATCH] 修改仿真后台
---
web/src/views/modules/taskReliability/TaskPhaseModel.vue | 148 ++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 114 insertions(+), 34 deletions(-)
diff --git a/web/src/views/modules/taskReliability/TaskPhaseModel.vue b/web/src/views/modules/taskReliability/TaskPhaseModel.vue
index d556748..19f0b72 100644
--- a/web/src/views/modules/taskReliability/TaskPhaseModel.vue
+++ b/web/src/views/modules/taskReliability/TaskPhaseModel.vue
@@ -2,49 +2,65 @@
<div class="mod-taskReliability-taskPhaseModel fa-card-a" style="margin-left: 5px;">
<zt-table-wraper ref="tableObj" defaultNotQuery="true" query-url="/taskReliability/TaskPhaseModel/page"
:paging='false'
+ @dataLoaded="dataLoaded"
delete-url="/taskReliability/TaskPhaseModel/" v-slot="{ table }">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
<el-form-item>
+ <zt-button v-if="dataForm.phaseId" type="warning" @click="handleSaveRows">淇濆瓨</zt-button>
</el-form-item>
</el-form>
<el-table v-loading="table.dataLoading" :data="table.dataList" height="100px"
- v-adaptive="{bottomOffset:30}" border @selection-change="table.selectionChangeHandle"
- row-key="id"
- :cell-style="cellStyle"
- :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
- :default-expand-all="true">
- <el-table-column prop="system" label="绯荤粺" width="160"/>
- <el-table-column prop="modelName" label="绯荤粺妯″瀷"/>
- <zt-table-column-handle :table="table" edit-perm="taskReliability:update"
- delete-perm="taskReliability::delete" :has-view="false">
- <template v-slot="{ row }">
- <zt-table-button @click="selectModel(row)">閫夋嫨妯″瀷</zt-table-button>
+ v-adaptive="{bottomOffset:30}" border
+ @cell-click="handleCellClick"
+ @selection-change="table.selectionChangeHandle">
+ <el-table-column prop="operatConditName" label="宸ュ喌鍚嶇О" width="140" align="center"/>
+ <el-table-column prop="operatConditDurationRate" label="宸ュ喌鏃堕暱姣�" align="right" width="120">
+ <template slot-scope="scope">
+ <span
+ v-if="editingCell && editingCell.row === scope.row && editingCell.column.property === scope.column.property">
+ <el-input ref="editInput"
+ autosize v-model="scope.row.operatConditDurationRate"
+ placeholder="宸ュ喌鏃堕暱姣�" @input="change()"></el-input>
+ </span>
+ <span v-else>{{scope.row.operatConditDurationRate}}</span>
</template>
- </zt-table-column-handle>
+ </el-table-column>
+ <el-table-column align="center" label="閫夌敤">
+ <template v-slot="{ row }">
+ <el-checkbox true-label="1" false-label="0" v-model="row.isCheck" @change="change"></el-checkbox>
+ </template>
+ </el-table-column>
</el-table>
- <select-model-rbd ref="SelectModelRbd" @setModel="selectModelRbd"></select-model-rbd>
</zt-table-wraper>
</div>
</template>
<script>
- import SelectModelRbd from "./SelectModelRbd";
+ import cloneDeep from 'lodash/cloneDeep'
export default {
name: 'TaskPhaseModel',
data() {
return {
dataForm: {
- phaseId: '',
- modelName: '',
productId: '',
- modelId: '',
- }
+ phaseId: '',
+ operatConditName: '',
+ operatConditId: '',
+ operatConditDurationRate: '',
+ dataList: [],
+ isCheck: '',
+ dataThreeList:[]
+ },
+ lastSaveData: [],
+ isChange: false,
+ editingCell: null,
+ dataList: [],
+ originalTableData: [],
+ originalData: null,
}
},
- components: {
- SelectModelRbd
- },
+ components: {},
methods: {
init(param) {
console.log(param, '')
@@ -52,23 +68,87 @@
this.dataForm.productId = param.productId
this.$refs.tableObj.query()
},
- cellStyle({column}) {
- if (column.label === '绯荤粺') {
- return 'text-align: left !important;'
+ //鎵归噺淇濆瓨
+ async handleSaveRows() {
+ let operatConditDurationRate = null
+ let flag = true
+ let list = []
+ let reg = /^(-?\d+)\.?(\d*)$/;
+ this.dataForm.dataThreeList = this.$refs.tableObj.dataList
+ for (let i = 0; i < this.dataForm.dataThreeList.length; i++) {
+ operatConditDurationRate = this.dataForm.dataThreeList[i].operatConditDurationRate
+ console.log(operatConditDurationRate)
+ if (this.dataForm.dataThreeList[i].operatConditDurationRate == null)
+ this.dataForm.dataThreeList[i].operatConditDurationRate = '0'
+ if (this.dataForm.dataThreeList[i].isCheck === '0')
+ this.dataForm.dataThreeList[i].operatConditDurationRate = '0'
+ if (String(operatConditDurationRate).match(reg) == null && operatConditDurationRate !== null) {
+ this.$alert("杈撳叆鐨勬暟鎹牸寮忔湁璇�")
+ flag = false
+ }
+ // time = time + Number(this.dataForm.dataThreeList[i].operatConditDurationRate)
+ if (this.dataForm.dataThreeList[i].isCheck === '1' && (this.dataForm.dataThreeList[i].operatConditDurationRate == null || this.dataForm.dataThreeList[i].operatConditDurationRate == 0)) {
+ this.$alert("鏈夋湭濉啓鐨勫伐鍐垫椂闀�")
+ flag = false
+ }
+ list.push(this.dataForm.dataThreeList[i])
+ }
+ this.dataForm.dataThreeList = list
+ /*console.log(time, 'async handleSaveRows')
+ if (time > 1) {
+ this.$alert("璇烽噸鏂拌缃綋鍓嶆椂闀挎瘮鍒嗛厤")
+ return
+ }*/
+ if (!flag) {
+ return
+ }
+ let res = await this.$http.post('/taskReliability/TaskPhaseModel/save', this.dataForm)
+ if (res.success) {
+ this.isChange = false;
+ this.lastSaveData = cloneDeep(list)
+ console.log(res.data)
+ await this.$tip.success()
+ this.originalData = null
+ this.dataForm.dataThreeList = null
+ this.$refs.tableObj.query()
+ this.$emit('getList')
+ this.originalTableData = JSON.parse(JSON.stringify(this.dataList)); // 鏇存柊鍒濆鏁版嵁涓哄綋鍓嶆暟鎹�
+ console.log(this.originalTableData, 'this.originalTableData 褰撳墠琛ㄦ牸json鏁版嵁')
}
},
- selectModel(row) {
- console.log(row, 'selectModel');
- let param = {
- row: row,
- phaseId: this.dataForm.phaseId
+ dataLoaded(data) {
+ this.dataList = data
+ for (let i = 0; i < this.dataList.length; i++) {
+ this.dataList[i].productId = this.dataForm.productId
+ this.dataList[i].phaseId = this.dataForm.phaseId
}
- this.$refs.SelectModelRbd.$refs.dialog.init(param)
+ this.lastSaveData = cloneDeep(this.$refs.tableObj.dataList)
+ console.log(this.lastSaveData)
},
- selectModelRbd(row) {
- console.log(row, 'selectModelRbd')
- this.$refs.tableObj.query()
- }
+ handleCellClick(row, column) {
+ this.editingCell = {row, column}
+ this.$nextTick(() => {
+ if (this.$refs.editInput) {
+ this.$refs.editInput.focus()
+ }
+ })
+ console.log(this.editingCell, 'this.editingCell')
+ },
+ change() {
+ console.log(this.$refs.tableObj.dataList, "this.$refs.tableObj.dataList")
+ console.log(this.lastSaveData, "this.lastSaveData")
+
+ let r = JSON.stringify(this.$refs.tableObj.dataList);
+ let l = JSON.stringify(this.lastSaveData);
+ console.log(r,'this.$refs.tableObj.dataList[i]')
+ console.log(l,'this.lastSaveData[i]')
+ if (r!==l){
+ this.isChange = true
+ return
+ }
+ this.isChange = false
+ },
+
}
}
</script>
--
Gitblit v1.9.1