zouyu
2023-11-10 af3baa8feeef4f4cd9a0866884f3bc68d1512683
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<template>
  <basic-container>
    <el-row>
      <el-col :span="12">
        <ttable
          :table="table"
          @handleSelectionChange="handleSelectionChange"
          @currentChange="handleCurrentChange"
          :uploadInfo="uploadInfo"
          :prelang="prelang"
          :options="options"
          :ajaxFun="ajaxFun"
          :paramObj="paramObj"
          :bottomOffset="100"
          ref="selectTestStandardTable"
        >
          <template #toolbar></template>
        </ttable>
      </el-col>
      <el-col :span="12" style="padding-left: 10px">
        <el-table
          :data="testStandardParams"
          id="testStandardParamTable"
          ref="testStandardParam"
          :default-sort="{ prop: 'index' }"
          highlight-current-row
          height="500"
          style="width: 100%"
        >
          <el-table-column
            prop="index"
            label="序号"
            align="center"
            width="50"
          />
          <el-table-column label="参数编号" prop="code" align="center" />
          <el-table-column label="参数项" prop="parameterItem" align="center" />
          <el-table-column label="检测类型" prop="paramType" align="center" />
          <el-table-column
            label="检测范围"
            prop="referenceValue"
            align="center"
          />
          <el-table-column label="单位" prop="unit" align="center" />
        </el-table>
      </el-col>
    </el-row>
    <qualityStandardDialog
      :currshowlist.sync="showQualityStandard"
      :paramTemplateObj="qualityStandardParamObj"
      @listenToSelectTestStandardEvent="selectQualityStandard"
  /></basic-container>
</template>
<script>
import { getTestStandardParams } from '@/api/quality/teststandard'
import ttable from '@/views/common/ztt-table.vue'
import { mapGetters } from 'vuex'
import {
  deleteTestStandard,
  getTestStand,
  saveTestStandard
} from '../../../api/technology/document'
import qualityStandardDialog from '@/views/common/teststandardradio.vue'
 
export default {
  props: {
    documentId: {
      type: Number,
      default: 0
    },
    editable: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      paramObj: { documentId: this.documentId },
      showQualityStandard: false,
      testStandardParams: [],
      ajaxFun: getTestStand,
      currentRow: null,
      innerVisible: false,
      multipleSelection: [],
      isShowQuery: false,
      uploadInfo: {
        // 是否展示上传EXCEL以及对应的url
        isShow: false,
        url: ''
      },
      prelang: 'operationParamTemplate',
      options: {
        height: 300, // 默认高度-为了表头固定
        stripe: true, // 是否为斑马纹 table
        highlightCurrentRow: false, // 是否要高亮当前行
        border: true, // 是否有纵向边框
        lazy: false, // 是否需要懒加载
        fit: true, // 列的宽度是否自撑开
        multiSelect: true, //
        seqNo: true,
        isShowHide: true, // 是否显示显影按钮
        isSearch: true, // 高级查询按钮
        defaultOrderBy: { column: 'standardNo', direction: 'desc' }
      },
      table: {
        total: 0,
        currentPage: 1,
        pageSize: 20,
        data: [],
        // 标题
        column: [
          {
            minWidth: 'code',
            prop: 'standardNo',
            label: '标准编号',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            minWidth: '120',
            prop: 'standardName',
            label: '标准名称',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            minWidth: '120',
            prop: 'remark',
            label: '备注',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          }
        ],
        toolbar: [],
        operator: null,
        operatorConfig: {
          fixed: 'right',
          label: '操作',
          width: 100,
          minWidth: 100
        }
      },
      qualityStandardParamObj: null
    }
  },
  components: {
    ttable,
    qualityStandardDialog
  },
  watch: {
    editable: {
      immediate: true,
      handler() {
        if (this.editable) {
          this.table.toolbar = [
            {
              text: '新增',
              type: 'primary',
              fun: this.addOrUpdateHandle,
              disabled: false
            }
          ]
          this.table.operator = [
            {
              text: '删除',
              type: 'text',
              size: 'small',
              fun: this.deleteHandle
            }
          ]
        } else {
          this.table.toolbar = []
          this.table.operator = null
        }
      }
    }
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  created() {},
  methods: {
    // 获取数据列表
    getData() {
      this.$refs.selectTestStandardTable.getDataList()
    },
    addOrUpdateHandle() {
      console.info(this.documentId)
      if (this.documentId) {
        if (this.editable) {
          this.qualityStandardParamObj = {
            state: '02accepted'
          }
          this.showQualityStandard = true
        } else {
          this.$message.error('该状态下的工艺文件不可新增成品检测')
        }
      } else {
        this.$message.error('请先填写主表信息')
      }
    },
    selectQualityStandard(row) {
      if (row != null) {
        // 保存检测标准,查询检测项
        var qualityStandardObj = {
          documentId: this.documentId,
          testStandardId: row.id
        }
        const qualityStandards = []
        qualityStandards.push(qualityStandardObj)
        saveTestStandard(qualityStandards).then((response) => {
          const data = response.data
          if (data.code === 0) {
            this.$message.success('添加检测标准成功')
            this.getData()
          } else {
            this.$message.error('添加检测标准失败')
          }
        })
      }
    },
    deleteHandle(row) {
      if (this.editable) {
        this.$confirm('确定删除检测标准?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          closeOnClickModal: false,
          type: 'warning'
        })
          .then(() => {
            var qualityStandardObj = {
              documentId: this.documentId,
              testStandardId: row.id
            }
            deleteTestStandard(qualityStandardObj).then((response) => {
              const data = response.data
              if (data.code === 0) {
                this.$message.success('删除检测标准成功')
                this.getData()
                this.testStandardParams = []
              } else {
                this.$message.error('删除检测标准失败')
              }
            })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
      } else {
        this.$message.error('该状态下的工艺文件不可删除成品检测')
      }
    },
    handleCurrentChange(row) {
      this.testStandardParams = []
      this.currentRow = row
      if (row && row.id) {
        this.getTestStandardParamData(row.id)
      }
    },
    // 获取关联的检测标准参数信息
    getTestStandardParamData(testStandardId) {
      getTestStandardParams(
        Object.assign({
          testStandardId: testStandardId
        })
      ).then((response) => {
        this.testStandardParams = response.data.data
      })
    },
    handleSelectionChange(val) {
      // 多行选中
      this.multipleSelection = val
    }
  }
}
</script>