cuijian
2025-07-04 e2ca529f2d095293d737b5a2f0b7562e85919418
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="检验方案编码">
              <a-input placeholder="请输入检验方案编码" v-model="queryParam.planCode" />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
              <a-form-item label="检验方案分类">
                <j-search-select-tag
                  placeholder="请选择检验方案分类"
                  v-model="queryParam.planCategory"
                  dict="plan_category"
                />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="info" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
            </a-col>
        </a-row>
      </a-form>
    </div>
 
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
    </div>
 
    <!-- table区域-begin -->
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      :customRow="customRow"
      :rowClassName="tableRowClass"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange,type:'radio'}"
      @change="handleTableChange"
    >
      <!--状态栏个性展示-->
        <span
          slot="status"
          slot-scope="text,record"
        >
          <a-badge
            v-if="record.planStatus==1"
            status="success"
          />
          <span
            v-if="record.planStatus==1"
            class="success"
          >启用</span>
          <a-badge
            v-if="record.planStatus==0"
            status="error"
          />
          <span
            v-if="record.planStatus==0"
            class="error"
          >禁用</span>
        </span>
        <span
          slot="publishStatus"
          slot-scope="text,record"
        >
          <a-badge
            v-if="record.publishStatus==1"
            status="success"
          />
          <span
            v-if="record.publishStatus==1"
            class="success"
          >已发布</span>
          <a-badge
            v-if="record.publishStatus==0"
            status="error"
          />
          <span
            v-if="record.publishStatus==0"
            class="error"
          >待发布</span>
        </span>
        <span
          slot="version"
          slot-scope="text,record"
        >
          <span
            v-if="record.planStatus==1"
            class="success"
          >{{record.version}}</span>       
          <span
            v-if="record.planStatus==0"
            class="error"
          >{{record.version}}</span>
        </span>
        <span
          slot="action"
          slot-scope="text, record"
          v-if="record.isNewVersion == 1"
        >
          <a-popconfirm
            v-if="record.publishStatus == 0 && record.planStatus == 1"
            title="确定发布吗?"
            @confirm="() => handlePublish(record.id)"
          >
            <a>发布</a>
          </a-popconfirm>
          <a-popconfirm
            v-if="record.publishStatus == 1 && record.planStatus == 1"
            title="确定取消发布吗?"
            @confirm="() => handlePublish(record.id)"
          >
            <a>取消发布</a>
          </a-popconfirm>
          <a-divider type="vertical" v-if="record.publishStatus == 1 && record.planStatus == 1"/>
           <a-popconfirm
            v-if="record.publishStatus == 1 && record.planStatus == 1"
            title="确定升版吗?"
            @confirm="() => handleVersion(record.id)"
          >
            <a>升版</a>
          </a-popconfirm>
          <a-divider type="vertical" v-if="record.planStatus == 1"/>
          <a-dropdown>
            <a class="ant-dropdown-link">更多
              <a-icon type="down" />
            </a>
            <a-menu slot="overlay">
              <a-menu-item v-if="record.planStatus==1 && record.publishStatus==0">
                <a @click="handleEdit(record)">编辑</a>
              </a-menu-item>
              <a-menu-item>
                <a
                  href="javascript:;"
                  @click="handleDetail(record)"
                >详情</a>
              </a-menu-item>
              <a-menu-item v-if="record.publishStatus==0">
                <a-popconfirm
                  title="确定删除吗?"
                  @confirm="() => handleDelete(record.id)"
                >
                  <a>删除</a>
                </a-popconfirm>
 
              </a-menu-item>
              <a-menu-item v-if="record.planStatus == 0">
                <a-popconfirm
                  title="确定启用吗?"
                  @confirm="() => handleActive(record.id)"
                >
                  <a>启用</a>
                </a-popconfirm>
              </a-menu-item>
              <a-menu-item v-if="record.planStatus == 1 && record.publishStatus == 0">
                <a-popconfirm
                  title="确定禁用吗?"
                  @confirm="() => handleActive(record.id)"
                >
                  <a>禁用</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
    </a-table>
    <a-tabs defaultActiveKey="1">
      <a-tab-pane tab="检验方案检验项明细" key="1">
        <inspection-plan-item-list ref="inspectionPlanItemList"></inspection-plan-item-list>
      </a-tab-pane>
    </a-tabs>
    <!-- table区域-end -->
    <inspection-plan-model ref="modalForm" @ok="modalFormOk"></inspection-plan-model>
  </a-card>
</template>
 
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import InspectionPlanModel from './modules/inspectionPlan/InspectionPlanModel'
import InspectionPlanItemList from './modules/inspectionPlan/InspectionPlanItemList'
import { requestPut,postAction,getAction } from '@/api/manage'
import JDictSelectTag from '@/components/dict/JDictSelectTag'
import JSearchSelectTag from '@/components/dict/JSearchSelectTag'
 
export default {
  name: 'InspectionPlanList',
  mixins: [JeecgListMixin],
  components: {
    InspectionPlanModel,
    InspectionPlanItemList,
    JDictSelectTag,
    JSearchSelectTag,
  },
  data() {
    return {
      description: '检验方案',
      url: {
        list: '/qms/inspectionPlan/list',
        importExcelUrl: '/qms/inspectionPlan/importExcel',
        exportXlsUrl: '/qms/inspectionPlan/exportXls',
        edit:'/qms/inspectionPlan/edit',
        submit:'/qms/inspectionPlan/submit',
        active: '/qms/inspectionPlan/active',
        publish:'/qms/inspectionPlan/publish',
        version:'/qms/inspectionPlan/version'
      },
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '检验方案编码',
          align: 'center',
          dataIndex: 'planCode',
          sorter: true,
        },
        {
          title: '检验方案名称',
          align: 'center',
          dataIndex: 'planName',
        },
        {
          title: '检验方案分类',
          align: 'center',
          dataIndex: 'planCategory_dictText',
        },
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'materialNumber',
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName',
        },
        {
          title: '抽样规则',
          align: 'center',
          dataIndex: 'ruleId_dictText',
        },
        {
          title: '方案描述',
          align: 'center',
          dataIndex: 'descreption',
        },
        {
          title: '版本',
          align: 'center',
          scopedSlots: {
            customRender: 'version',
          },
          dataIndex: 'version',
        },
        {
          title: '方案状态',
          align: 'center',
          scopedSlots: {
            customRender: 'status',
          },
          dataIndex: 'planStatus',
        },
        {
          title: '发布状态',
          align: 'center',
          scopedSlots: {
            customRender: 'publishStatus',
          },
          dataIndex: 'publishStatus',
        },
        {
          width: 180,
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],
      loading:false
    }
  },
  computed: {
    /* 导入路径页面重新计算 */
    importExcelUrl: function () {
      //  return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;//开发环境指向
      return `${window._CONFIG['hxFileURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    searchQuery(){
      this.selectedRowKeys = []
      this.$refs.inspectionPlanItemList.dataSource = []
      this.loadData(1);
    },
    searchReset() {
      this.queryParam = {}
      this.selectedRowKeys = []
      this.$refs.inspectionPlanItemList.dataSource = []
      this.loadData(1);
    },
    customRow(record) {
      return {
        on: {
          click: (e) => {
            this.onSelectChange(record.id.split(","), [record]); 
          },
        },
      }
    },
    onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
        //将当前选中的记录传到子页面
        this.$bus.$emit('getInspectionPlanItemData', this.selectionRows[0])
      },
    handleEdit: function (record) {
        this.$refs.modalForm.edit(record)
        this.$refs.modalForm.title = '编辑'
        this.$refs.modalForm.disableSubmit = false
    },
    handleAdd() {
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增'
      this.$refs.modalForm.disableSubmit = false
    },
    handleSubmit(record) {
        let that = this;
        that.loading = true
        getAction(that.url.submit, { id:record.id}).then((res) => {
          if (res.success) {
            that.$message.success(res.message);
            that.loadData();
          } else {
            that.$message.warning(res.message);
          }
        }).finally(() => {
          that.loading = false
        })
      },
       //启用禁用
    handleActive(id) {
      if (!this.url.active) {
        this.$message.error("请设置url.active!")
        return
      }
      let that = this;
      requestPut(that.url.active, {}, { id: id }).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
        }
      });
    },
 
    //发布
    handlePublish(id) {
      if (!this.url.publish) {
        this.$message.error("请设置url.publish!")
        return
      }
      let that = this;
      requestPut(that.url.publish, {}, { id: id }).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
        }
      });
    },
 
    //升版
    handleVersion(id) {
      if (!this.url.version) {
        this.$message.error("请设置url.version!")
        return
      }
      let that = this;
      requestPut(that.url.version, {}, { id: id }).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
        }
      });
    },
 
    tableRowClass(record, index) {
      if (record.isNewVersion != '1') {
        return "frozenRowClass";
      }
      return "";
    },
  },
}
</script>
 
<style lang="less" scoped>
@import '~@assets/less/common.less';
/deep/ .frozenRowClass {
  color: #c9c9c9;
}
/deep/ .notshow {
  display: none;
}
/deep/ .checked-td-of-add-table {
  background-color: rgba(220, 220, 220, 1);
}
</style>