lyh
2025-05-28 e14ed882d12df3b48e59390eba364442cdff70bd
src/views/tms/requirement/modules/ToolsSharpeningModal.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,286 @@
<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" 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" 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="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-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"></tools-modal>
  </j-modal>
</template>
<script>
import { getAction, postAction, requestPut } from '@/api/manage'
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
import ToolsModal from '@views/tms/requirement/modules/ToolsModal.vue'
export default {
  name: 'ToolsSharpeningModal',
  mixins: [JVxeTableModelMixin],
  components: {
    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: '请输入刃磨结果及建议!' }
        ]
      },
      url: {
        add: '/tms/toolSharpening/add',
        edit: '/tms/toolSharpening/edit',
        queryDetailList: '/tms/toolSharpening/listToolSharpening'
      }
    }
  },
  created() {
  },
  mounted() {
    this.$bus.$on('selectionRows', (data) => {
      console.log('selectionRows', data)
      if (data && data.length > 0) {
        const item = data[0]
        // ä½¿ç”¨ $set ç¡®ä¿ model çš„属性是响应式的
        this.$set(this.model, 'toolId', item.toolCode)
        this.$set(this.model, 'toolCode', item.id)
        this.$set(this.model, 'classifyId', item.classifyId)
        this.$set(this.model, 'paramaTableName', item.paramaTableName_dictText)
        this.$set(this.model, 'applicationType', 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)
      }
    })
  },
  methods: {
    selectTools: function() {
      this.$refs.toolListModel.showModals()
      this.$refs.toolListModel.title = '选择工具信息'
      this.$refs.toolListModel.disableSubmit = false
    },
    add() {
      this.addShow = false
      this.edit()
    },
    edit(record) {
      console.log(record)
      // this.model = Object.assign({}, record)
      this.visible = true
      getAction(this.url.queryDetailList, {
        id: record.id,
        pageNo: 1,
        pageSize: 99999
      }).then((res) => {
        if (res.success) {
          const readOnlyData = res.result.records[0] || {}
          this.model = Object.assign({}, this.model, {
            paramaTableName: readOnlyData.paramaTableName_dictText,
            applicationType: readOnlyData.applicationType_dictText,
            provinceCity: readOnlyData.provinceCity,
            warehouseId: readOnlyData.warehouseId,
            positionCode: readOnlyData.positionCode,
            mainUnit: readOnlyData.mainUnit,
            toolModel: readOnlyData.toolModel
          })
        } else {
          this.dataSource = null
        }
      })
    },
    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()
    },
    close() {
      this.$emit('close')
      this.visible = false
      this.$refs.form.clearValidate()
    }
  }
}
</script>
<style lang="less" scoped>
</style>