cuijian
2025-06-11 045bd52acc6cec67ae9b47200cb02301db1b54e3
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
<template>
  <j-modal
    :title="title"
    :width="1200"
    :visible="visible"
    centered
    :confirmLoading="confirmLoading"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
        <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 工具基础信息
        </a-divider>
 
        <a-row :gutter="24">
              <a-col :span="6">
                <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="classifyNum" label="工具分类编码">
                      <a-input placeholder="请输入工具分类编码" v-model="model.classifyNum" :disabled="true" />
                    </a-form-model-item>
                  </a-col>
                </a-row>
                <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="classifyName" label="工具分类名称">
                      <a-input placeholder="请输入工具分类名称" v-model="model.classifyName"  :disabled="true" />
                    </a-form-model-item>
                  </a-col>
                </a-row>
                <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="toolCode" label="工具编码">
                      <a-input :placeholder="disableSubmit?'':'请输入工具编码'" v-model="model.toolCode" :disabled="disableSubmit"/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-col>
 
              <a-col :span="6">
                <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="chineseName"
                                      label="中文名称">
                      <a-input :placeholder="disableSubmit?'':'请输入中文名称'" v-model="model.chineseName" :disabled="disableSubmit"/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
                 <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="foreignLanguageName"
                                      label="外文名称">
                      <a-input :placeholder="disableSubmit?'':'请输入外文名称'" v-model="model.foreignLanguageName" :disabled="disableSubmit" />
                    </a-form-model-item>
                  </a-col>
                </a-row>
                <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="toolModel"
                                      label="型号/图号">
                      <a-input :placeholder="disableSubmit?'':'请输入型号/图号'" v-model="model.toolModel" :disabled="disableSubmit" />
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-col>
 
              <a-col :span="6">
              <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="standardLevel"
                                      label="标注级别">
                      <a-input :placeholder="disableSubmit?'':'请输入标准级别'" v-model="model.standardLevel" :disabled="disableSubmit"/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
                 <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="standardCode" label="标准号">
                      <a-input :placeholder="disableSubmit?'':'请输入标准号'" v-model="model.standardCode" :disabled="disableSubmit"/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
                <a-row>
                  <a-col :span="24">
                    <a-form-model-item prop="signCode" label="序号">
                      <a-input :placeholder="disableSubmit?'':'请输入序号'" v-model="model.signCode" :disabled="disableSubmit"/>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-col>
 
              <a-col :span="6">
                 <a-row>
                  <a-col :span="24">
                    <a-form-model-item label='' :labelCol='labelCol' :wrapperCol='wrapperCol'>
                      <j-image-upload text='上传工具图片' v-model='model.toolPicture'></j-image-upload>
                    </a-form-model-item>
                  </a-col>
                 </a-row>
              </a-col>
            </a-row>
        <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 管理参数
        </a-divider>
 
        <a-row :gutter="24">
           <a-col :span="8">
                <a-form-model-item prop="applicationType"
                                   label="工具类型">
                  <j-dict-select-tag dict-code="equipment_category" :placeholder="disableSubmit?'':'请选择工具类型'"
                                     v-model="model.applicationType" :disabled="disableSubmit" />
                </a-form-model-item>
              </a-col>
           <a-col :span="8">
            <a-form-model-item prop="provinceCity" label="仓库省份城市">
              <a-input :placeholder="disableSubmit?'':'请输入仓库省份城市'" v-model="model.provinceCity" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item prop="positionCode" label="库位号">
              <a-input :placeholder="disableSubmit?'':'请输入库位号'" v-model="model.positionCode" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
        </a-row>
 
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item prop="storageLocation" label="存储位置">
              <a-input :placeholder="disableSubmit?'':'请输入存储位置'" v-model="model.storageLocation" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item prop="lowerInventory" label="最低库存">
              <a-input :placeholder="disableSubmit?'':'请输入最低库存'" v-model="model.lowerInventory" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item prop="highestInventory" label="最高库存">
              <a-input :placeholder="disableSubmit?'':'请输入最高库存'" v-model="model.highestInventory" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
        </a-row>
 
        <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item prop="auxiliaryUnitFlag" label="是否有计量辅单位">
              <a-radio-group v-model="model.auxiliaryUnitFlag" :placeholder="disableSubmit?'':'请选择是否有计量辅单位'" :disabled="disableSubmit">
                <a-radio :value="'1'">是</a-radio>
                <a-radio :value="'2'">否</a-radio>
              </a-radio-group>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item prop="mainUnit" label="计量主单位">
              <a-input :placeholder="disableSubmit?'':'请输入计量主单位'" v-model="model.mainUnit" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item prop="auxiliaryUnit" label="计量辅单位">
              <a-input :placeholder="disableSubmit?'':'请输入计量辅单位'" v-model="model.auxiliaryUnit" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
        </a-row>
 
         <a-row :gutter="24">
          <a-col :span="8">
            <a-form-model-item prop="supplierId" label="厂家">
              <a-input :placeholder="disableSubmit?'':'请输入厂家'" v-model="model.supplierId" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item prop="price" label="单价">
              <a-input :placeholder="disableSubmit?'':'请输入单价'" v-model="model.price" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-model-item :labelCol="labelColLong" :wrapperCol="wrapperColLong" prop="remark" label="备注">
              <a-textarea :placeholder="disableSubmit?'':'请输入备注'" v-model="model.remark" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>
 
<script>
import { getAction,postAction, httpAction } from '@/api/manage'
import { validateDuplicateValueInDelFlag } from '@/utils/util'
import JSelectProduction from '@comp/jeecgbiz/JSelectProduction.vue'
import { getSystemConfigValue } from '@api/api'
  import { duplicateCheck } from '@/api/api'//重复校验
 
export default {
  name: 'ParaHoleToolsModal',
  components: { JSelectProduction },
  data() {
    return {
      title: '操作',
      visible: false,
      //控制编辑
      editable: false,
      //详情控制
      disableSubmit: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 9 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 14 }
      },
      labelColLong: {
        xs: { span: 24 },
        sm: { span: 2 }
      },
      wrapperColLong: {
        xs: { span: 24 },
        sm: { span: 22 }
      },
      confirmLoading: false,
      validatorRules: {
        toolCode: [
          { required: true, message: '请输入工具编码' },
          { validator: this.validateNum }
        ],
        classifyNum: [
          { required: true, message: '请输入工具分类编码' }
        ],
        classifyName: [
          { required: true, message: '请输入工具分类名称' }
        ],
        toolModel: [
          { required: true, message: '请输入型号/图号' },
           { validator: this.validateModel }
        ],
        chineseName: [
          { required: true, message: '请输入中文名称' }
        ]
      },
      url: {
        add: '/tms/baseTools/add',
        edit: '/tms/baseTools/edit',
      },
    }
  },
  created() {
  },
  methods: {
    add(nodeSelected) {
      this.editable = false;
      //初始化默认值
      this.model = {};
      this.model.classifyId = nodeSelected.key
      this.model.classifyNum = nodeSelected.entity.classifyId
      this.model.classifyName = nodeSelected.entity.typeName
      this.model.paraTypeFlag = nodeSelected.entity.paraTypeFlag
      this.visible = true
    },
    edit(record) {
      this.editable = true;
      this.model = Object.assign({}, record)
      this.visible = true
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.$refs.form.clearValidate()
    },
    handleOk() {
      const that = this
      // 触发表单验证
      this.$refs.form.validate(valid => {
        if (valid) {
          that.confirmLoading = true
          let formData = Object.assign(this.model)
          let httpUrl = ''
            let method = 'post'
            if (!this.model.id) {
              httpUrl += this.url.add
            } else {
              httpUrl += this.url.edit
            }
           httpAction(httpUrl, formData, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message)
               that.$emit('ok')
              } else {
                that.$message.warning(res.message)
              }
            })
            .finally(() => {
              that.confirmLoading = false
              that.close()
            })
        }
      })
    },
    handleCancel() {
      this.close()
    },
      //验证工具编码是否重复
    validateNum(rule, value, callback) {
      var params = {
        tableName: 'tms_base_tools',
        fieldName: 'tool_code',
        fieldVal: value,
        dataId: this.model.id
      };
      duplicateCheck(params).then((res) => {
        if (res.success) {
          callback()
        } else {
          callback("工具编码已存在!")
        }
      })
    },
      //验证型号/图号是否重复
    validateModel(rule, value, callback) {
      var params = {
        tableName: 'tms_base_tools',
        fieldName: 'tool_model',
        fieldVal: value,
        dataId: this.model.id
      };
      duplicateCheck(params).then((res) => {
        if (res.success) {
          callback()
        } else {
          callback("型号/图号已存在!")
        }
      })
    },
  }
}
</script>
 
<style lang="less" scoped>
/deep/ .ant-modal-body {
  padding: 0 24px;
}
 
/deep/ .ant-upload {
  width: 185px;
  height: 185px;
}
 
/deep/ .img {
  display: flex;
  justify-content: center;
 
  .ant-upload-picture-card-wrapper {
    width: auto;
  }
}
 
/deep/ .ant-upload-list-picture-card-container {
  width: 185px;
  height: 185px;
}
 
/deep/ .ant-upload-list-item {
  width: 185px;
  height: 185px;
}
</style>