cuilei
2025-06-16 1b8b8bafca4fe4c3556bda5e66e3ff6252bd7acc
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
<template>
  <j-modal
    :title="title"
    :width="1200"
    :confirmLoading="confirmLoading"
    switchFullscreen
    centered
    :visible="visible"
    :mask-closable="false"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
 
 
 
    <a-spin :spinning="spinning">
      <a-form-model ref="form" :model="model" :rules="validatorRules" :labelCol="labelCol" :wrapperCol="wrapperCol">
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item prop="standardCode" label="工具编码">
              <a-input-search v-model="model.toolId" placeholder="请选择工具编码" :disabled="disableSubmit"
                              @search="selectTools" enter-button
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item prop="classify_id" label="工具分类名称">
              <a-input placeholder="请输入工具分类名称" v-model="model.classifyId" readOnly :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
 
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item prop="paramaTableName" label="工具参数标识">
              <a-input placeholder="选择设备后自动带出" readOnly v-model="model.paramaTableName_dictText" readOnly
                       :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="工具类型">
              <a-input placeholder="选择设备后自动带出" v-model="model.applicationType_dictText" readOnly
                       :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
        </a-row>
 
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item prop="responsiblePerson" label="责任人">
              <j-dict-select-tag type="list" v-model="model.responsiblePerson" dictCode="sys_user,realname,id"
                                 placeholder="请选择责任人" :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="刃磨时间" prop="sharpeningTime">
              <j-date placeholder="请选择刃磨时间" date-format="YYYY-MM-DD HH:mm:ss" v-model="model.sharpeningTime"
                      style="width: 100%" :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
        </a-row>
 
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item label="刃磨结果及建议" prop="sharpeningResult">
              <a-textarea placeholder="选择填写刃磨结果及建议" v-model="model.sharpeningResult"
                          :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="型号/图号">
              <a-input placeholder="选择填写型号/图号" v-model="model.toolModel" :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item label="仓库城市" prop="inspectionDate">
              <a-input placeholder="选择填写仓库省份城市" v-model="model.provinceCity" readOnly
                       :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="库区/库号">
              <a-input placeholder="选择填写库区/库号" v-model="model.warehouseId" readOnly :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item label="存储位置" prop="storageLocation">
              <a-input placeholder="选择填写存储位置" v-model="model.positionCode" readOnly
                       :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="计量主单位">
              <a-input placeholder="请填写计量主单位" v-model="model.mainUnit" readOnly :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="12">
            <a-form-model-item label="备注" prop="remark">
              <a-textarea v-model="model.remark" rows="3" placeholder="请输入备注" :disabled="disableSubmit" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
    <template slot="footer">
      <a-button :style="{ marginRight: '8px' }" @click="handleCancel()">
        关闭
      </a-button>
 
      <a-button @click="handleOk()" :disabled="disableSubmit" type="primary" :loading="confirmLoading">确定</a-button>
    </template>
    <tools-modal ref="toolListModel"  @sendSelectionRows="getRows"></tools-modal>
 
 
  </j-modal>
</template>
 
<script>
 
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
import ToolsModal from '@views/tms/requirement/modules/ToolsModal.vue'
import DeviceListModel from '@views/mdc/base/modules/EquipmentList/DeviceListModal.vue'
import { requestPut, postAction, httpAction } from '@/api/manage'
export default {
  name: 'ToolsSharpeningModal',
  mixins: [JVxeTableModelMixin],
  components: {
    DeviceListModel,
    ToolsModal
  },
  data() {
    return {
      title: '操作',
      visible: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 }
      },
      confirmLoading: false,
      spinning: false,
      disabled: false,
      disableSubmit: false,
      validatorRules: {
 
        sharpeningTime: [
          { required: true, message: '请选择刃磨日期!' }
        ],
        responsiblePerson: [
          { required: true, message: '请选择责任人!' }
        ],
        sharpeningResult: [
          { required: true, message: '请输入刃磨结果及建议!' }
        ]
      },
      lastSelectionData: null,
      url: {
        add: '/tms/toolSharpening/add',
        edit: '/tms/toolSharpening/edit'
      }
    }
  },
  created() {
  },
 
  methods: {
    getRows(item) {
      console.log(item)
      if (item.id) {
        this.$set(this.model, 'toolId', item.toolId)
        this.$set(this.model, 'toolCode', item.toolCode)
        this.$set(this.model, 'classifyId', item.classifyId)
        this.$set(this.model, 'paramaTableName_dictText', item.paramaTableName_dictText)
        this.$set(this.model, 'applicationType_dictText', item.applicationType_dictText)
        this.$set(this.model, 'toolModel', item.toolModel)
        this.$set(this.model, 'provinceCity', item.provinceCity)
        this.$set(this.model, 'warehouseId', item.warehouseId)
        this.$set(this.model, 'positionCode', item.positionCode)
        this.$set(this.model, 'mainUnit', item.mainUnit)
      }
    },
 
    selectTools: function() {
      this.$refs.toolListModel.showModals()
      this.$refs.toolListModel.title = '选择工具信息'
      this.$refs.toolListModel.disableSubmit = false
    },
 
    add() {
      this.edit({})
    },
    edit(record) {
      let that = this
      that.visible = true
      that.model = Object.assign({}, record)
    },
 
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      const that = this
      // 触发表单验证
      this.$refs.form.validate(valid => {
        if (valid) {
          let formData = Object.assign(this.model)
          that.confirmLoading = true
          let httpurl = ''
          let method = ''
          if (!this.model.id) {
            httpurl += this.url.add
            method = 'post'
          } else {
            httpurl += this.url.edit
            method = 'put'
          }
          httpAction(httpurl, this.model, method,formData).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()
          })
        } else {
          return false
        }
      })
    },
    // handleOk() {
    //   const that = this
    //   that.confirmLoading = true
    //
    //   // ✅ 触发表单验证
    //   this.$refs.form.validate(valid => {
    //     if (valid) {
    //       let formData = Object.assign(this.model)
    //
    //       let obj
    //       if (!this.model.id) {
    //         obj = postAction(this.url.add, formData)
    //       } else {
    //         obj = requestPut(this.url.edit, formData, { id: this.model.id })
    //       }
    //
    //       obj.then((res) => {
    //         if (res.success) {
    //           that.$message.success(res.message)
    //           that.$emit('ok')
    //           that.close()
    //         } else {
    //           that.$message.warning(res.message)
    //         }
    //       }).finally(() => {
    //         that.confirmLoading = false
    //       })
    //     } else {
    //       that.$message.warning('请填写必填字段')
    //       that.confirmLoading = false
    //       return false
    //     }
    //   })
    // },
 
    handleCancel() {
      this.close()
    },
 
 
  }
}
</script>
 
<style lang="less" scoped>
 
</style>