src/views/spare/modules/sparePartScrapRequirement/SparePartScrapRequirementForm.vue
@@ -18,12 +18,20 @@
                v-model='model.departId'
                dictCode="sys_depart,depart_name,id,del_flag!='1'"
              />-->
              <a-select
              <a-tree-select
                style="width: 100%"
                :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                :tree-data="treeData"
                placeholder="请选择申请部门"
                tree-default-expand-all
                v-model='model.departId'
              />
<!--              <a-select
                :placeholder="'请选择申请部门'"
                :options="this.departs"
                style="width: 100%"
                v-model='model.departId'
              />
              />-->
            </a-form-model-item>
          </a-col>
          <a-col :span='12'>
@@ -51,7 +59,10 @@
          :dataSource='sparesScrapRequirementDetailTable.dataSource'
          :maxHeight='300'
          :disabled='formDisabled'
          @valueChange="changeAuxiliaryQuantity"
          :alwaysEdit='true'
          :rowNumber='true'
          :bordered='bordered'
          :rowSelection='true'
          :toolbar='true'
          :toolbarConfig='toolbarConfig'
@@ -92,6 +103,8 @@
  },
  data() {
    return {
      treeData:[],
      bordered:true,
      departs: [],
      labelCol: {
        xs: { span: 24 },
@@ -133,6 +146,7 @@
            title: '备件编码',
            key: 'spareNum',
            fixed: 'left',
            align:'center',
            type: JVXETypes.normal,
            width: '200px',
            placeholder: '请输入${title}',
@@ -141,6 +155,7 @@
          {
            title: '备件名称',
            key: 'spareName',
            align:'center',
            fixed: 'left',
            type: JVXETypes.normal,
            width: '200px',
@@ -151,6 +166,7 @@
            title: '型号',
            key: 'model',
            type: JVXETypes.normal,
            align:'center',
            width: '200px',
            placeholder: '请输入${title}',
            defaultValue: ''
@@ -159,6 +175,7 @@
            title: '规格',
            key: 'specification',
            type: JVXETypes.normal,
            align:'center',
            width: '200px',
            placeholder: '请输入${title}',
            defaultValue: ''
@@ -168,6 +185,7 @@
            title: '主单位',
            key: 'mainUnitIdName',
            type: JVXETypes.normal,
            align:'center',
            width: '200px',
            placeholder: '请输入${title}',
            defaultValue: ''
@@ -176,6 +194,7 @@
            title: '主单位',
            key: 'mainUnitId',
            type: JVXETypes.hidden,
            align:'center',
            width: '200px',
            placeholder: '请输入${title}',
            defaultValue: ''
@@ -183,6 +202,7 @@
          {
            title: '辅单位',
            key: 'auxiliaryUnitIdName',
            align:'center',
            type: JVXETypes.normal,
            width: '200px',
            placeholder: '请输入${title}',
@@ -192,6 +212,7 @@
            title: '辅单位',
            key: 'auxiliaryUnitId',
            type: JVXETypes.hidden,
            align:'center',
            width: '200px',
            placeholder: '请输入${title}',
            defaultValue: ''
@@ -200,19 +221,22 @@
            title: '主数量',
            key: 'mainQuantity',
            type: JVXETypes.inputNumber,
            align:'center',
            width: '200px',
            placeholder: '请输入${title}',
            defaultValue: 0,
            formatter({ cellValue, row, column }) {
            Function({cellValue, row, column}){
              console.log(cellValue)
              console.log(row)
              console.log(column)
              if (cellValue != null) {
                let conversionRatio = row.conversionRatio
                console.log(conversionRatio)
                row.auxiliaryQuantity = Math.abs(cellValue * conversionRatio)
              }
              console.log(cellValue)
              return cellValue
            },
            validateRules: [
              {
@@ -236,6 +260,7 @@
            key: 'auxiliaryQuantity',
            type: JVXETypes.normal,
            width: '200px',
            align:'center',
            placeholder: '请输入${title}',
            defaultValue: 0
          },
@@ -243,6 +268,7 @@
            title: '备件id',
            key: 'sparePartId',
            type: JVXETypes.hidden,
            align:'center',
            width: '200px',
            placeholder: '请输入${title}',
            defaultValue: ''
@@ -251,6 +277,7 @@
            title: '换算比例',
            key: 'conversionRatio',
            type: JVXETypes.hidden,
            align:'center',
            width: '200px',
            placeholder: '请输入${title}',
            defaultValue: ''
@@ -260,6 +287,7 @@
            title: '需求日期',
            key: 'requirementTime',
            type: JVXETypes.date,
            align:'center',
            width: '200px',
            placeholder: '请输入${title}',
            defaultValue: '',
@@ -277,6 +305,7 @@
        add: '/spare/sparePartRequirement/add',
        edit: '/spare/sparePartRequirement/edit',
        queryById: '/spare/sparePartRequirement/queryById',
        loadOptions: '/sys/sysDepart/loadDepartTreeOptions',
        getSysDeparts: "/eam/equipment/getSysDeparts",
        sparesScrapRequirementDetail: {
          list: '/spare/sparePartRequirement/querySparesScrapRequirementDetailByMainId'
@@ -310,9 +339,18 @@
    })
  },
  created() {
    this.getSysDeparts()
    this.initOptions()
  },
  methods: {
    initOptions() {
      getAction(this.url.loadOptions).then(res => {
        if (res.success) {
          this.treeData = res.result
        } else {
          this.$message.warning(res.message)
        }
      })
    },
    getSysDeparts() {
      getAction(this.url.getSysDeparts).then((res) => {
        if (res.success) {
@@ -359,8 +397,6 @@
            auxiliaryUnitId: data[i].auxiliaryUnitId,
            mainUnitIdName: data[i].mainUnitId_dictText,
            auxiliaryUnitIdName: data[i].auxiliaryUnitId_dictText,
            mainQuantity: data[i].mainQuantity,
            auxiliaryQuantity: data[i].auxiliaryQuantity,
            requirementTime: data[i].requirementTime,
            conversionRatio: data[i].conversionRatio
@@ -423,6 +459,13 @@
      this.visible = false
      this.$emit('close')
      this.$refs.form.clearValidate()
    },
    changeAuxiliaryQuantity(target){
      console.log(target.columnIndex)
      let num=target.columnIndex
      if (target.columnIndex ===num){
        target.row.auxiliaryQuantity=Math.abs(target.row.conversionRatio*target.row.mainQuantity)
      }
    }
  }
}