whj 1 жил өмнө
parent
commit
ce601b3356

+ 17 - 1
src/api/store/outstoreform.js

@@ -52,7 +52,23 @@ export function addOutStoreFormYY (parameter) {
     data: parameter
   })
 }
-
+/**
+ * add func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function addOutStoreBackFormYY (parameter) {
+  return axios({
+    url: '/store/out-store-forms/yongyou/back',
+    method: 'POST',
+    headers: {
+      'Accept': 'application/json',
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    data: parameter
+  })
+}
 /**
  * update func
  * parameter: { }

+ 8 - 5
src/views/store/outstoreform/OutStoreFormYY.vue

@@ -71,7 +71,7 @@
       </div>
 
       <div class="table-operator" style="margin-bottom: 8px;">
-        <a-button v-if="$auth('store-out-store-forms-add')" type="primary" icon="plus" @click="handleAdd()">新增</a-button>
+        <a-button v-if="$auth('store-out-store-forms-add')" type="primary" icon="plus" @click="handleAdd()">{{ outFlag?'新增':'退库申请' }}</a-button>
         <a-button style="margin-left: 8px" v-if="$auth('store-out-store-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
         <!--<a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('store-out-store-forms-del')">
           <a-menu slot="overlay">
@@ -97,8 +97,8 @@
         <span slot="action" slot-scope="record">
           <template>
             <a @click="handleView(record)">查看</a>
-            <a-divider v-if="(record.status==0 || record.status == 3)" type="vertical" />
-            <a v-if="$auth('store-out-store-forms-edit')&&(record.status==0 || record.status == 3)" @click="handleEdit(record)">修改</a>
+            <a-divider v-if="(record.status==0 || record.status == 3)&&outFlag" type="vertical" />
+            <a v-if="$auth('store-out-store-forms-edit')&&(record.status==0 || record.status == 3)&&outFlag" @click="handleEdit(record)">修改</a>
             <a-divider v-if="record.status == 0 || record.status == 5 || record.status == 4" type="vertical" />
             <a v-if="record.status == 4 || record.status == 5" @click="handleViewTicket(record)">打印</a>
             <a-divider v-if="record.status==0" type="vertical" />
@@ -128,6 +128,7 @@
     </div>
     <detail ref="detailModal" @ok="handleOk"/>
     <base-form ref="baseModal" @ok="handleOk"/>
+    <base-form-back ref="baseBackModal" @ok="handleOk"/>
     <ticket-form ref="ticketForm" @ok="handleOk" />
 
   </a-card>
@@ -136,6 +137,7 @@
 <script>
 import { STable, Ellipsis } from '@/components'
 import BaseForm from './modules/BaseFormYY'
+import BaseFormBack from './modules/BaseFormBackYY'
 import Detail from './modules/DetailYY'
 import TicketForm from './modules/TicketForm'
 
@@ -150,6 +152,7 @@ export default {
     Ellipsis,
     BaseForm,
     TicketForm,
+    BaseFormBack,
     Detail
   },
   props: {
@@ -334,13 +337,13 @@ export default {
     },
     handleAdd () {
       this.visible = false
-      const modal = this.$refs.baseModal
+      const modal = this.outFlag ? this.$refs.baseModal : this.$refs.baseBackModal
       modal.base({ outFlag: this.outFlag }, {})
     },
     handleEdit (record) {
       this.visible = false
       fetchOutStoreForm({ id: record.id }).then(res => {
-        const modal = this.$refs.baseModal
+        const modal = this.outFlag ? this.$refs.baseModal : this.$refs.baseBackModal
         res.data.storeName = record.storeName
         modal.base(res.data)
       })

+ 524 - 0
src/views/store/outstoreform/modules/BaseFormBackYY.vue

@@ -0,0 +1,524 @@
+<template>
+  <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
+    <a-form :form="form">
+      <a-form-item v-show="false" >
+        <a-input v-decorator="['id']" type="hidden"/>
+        <a-input v-decorator="['storeId']" type="hidden"/>
+        <a-input v-decorator="['pickId']" type="hidden"/>
+        <a-input v-decorator="['outFlag']" type="hidden"/>
+        <a-input v-decorator="['outStoreFormId']" type="hidden"/>
+      </a-form-item>
+      <a-row :gutter="24">
+        <a-col :lg="12" :md="24" :sm="24">
+          <a-form-item
+            label="出库单号"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input
+              disabled
+              style="width: 70%"
+              v-decorator="['outNo', {rules: [{required: false, message: '出库单号不能为空'}]}]" />
+            <a-button type="primary" style="width: 30%" @click="handleSparePickFormSelect">选择</a-button>
+
+          </a-form-item>
+        </a-col>
+      </a-row>
+    </a-form>
+    <title-divider title="备件明细" width="90px"></title-divider>
+    <!-- <div class="table-operator" style="margin-bottom: 8px;">
+      <a-button size="small" type="primary" @click="handleSpareStoreSelect">
+        <a-icon type="plus"/>
+        添加
+      </a-button>
+      <a-button class="margin-left8" size="small" type="danger" @click="handleDel">
+        <a-icon type="delete"/>
+        删除
+      </a-button>
+    </div> -->
+    <a-table
+      bordered
+      :data-source="data"
+      :columns="columns"
+      tableLayout="auto"
+      rowKey="autoId"
+      :row-selection="rowSelection">
+      <template slot="num" slot-scope="text, record">
+        <div class="editable-cell-input-wrapper">
+          <a-input :value="text" :id="record.autoId + ',num'" @change="$event => onQuantityChange($event, record.autoId, 'num')" />
+        </div>
+      </template>
+      <template slot="remark" slot-scope="text, record">
+        <div>
+          <a-input v-model="record.remark" />
+        </div>
+      </template>
+      <span slot="action" slot-scope="record">
+        <template>
+          <a @click="handleBaseFormForModifySelect(record)">修改</a>
+          <a-divider type="vertical" />
+          <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelOne(record)">
+            <a>删除</a>
+          </a-popconfirm>
+        </template>
+      </span>
+    </a-table>
+    <a-row :gutter="48" >
+      <a-col :md="48" :sm="48">
+        <span class="table-page-search-submitButtons" style="float: right;margin-top: 10px">
+          <a-button :loading="confirmLoading" type="primary" @click="save()">提交</a-button>
+          <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
+        </span>
+      </a-col>
+    </a-row>
+    <spare-pick-form-select-modal ref="sparePickFormSelectModal" @selected="handleSparePickFormSelected"/>
+    <spare-back-form-select-modal ref="spareBackFormSelectModal" @selected="handleSpareBackFormSelected"/>
+    <spare-store-select-modal ref="spareStoreSelectModal" @selected="handleSpareStoreSelected"/>
+    <detail-base-form ref="detailBaseForm" @selected="handleDetailSelected"/>
+    <store-select-modal ref="storeSelectModal" @selected="handleStoreSelected"/>
+    <base-form-for-modify ref="baseFormForModify" @selected="handleBaseFormForModifySelected"/>
+    <OutStoreFormSelectModal ref="outStoreFormSelectModal" @selected="handleOutStoreSelected" />
+  </a-card>
+</template>
+
+<script>
+import pick from 'lodash.pick'
+import { addOutStoreBackFormYY, updateOutStoreFormYY, fetchOutStoreForm } from '@/api/store/outstoreform'
+import SparePickFormSelectModal from '@/views/store/sparepickform/modules/SparePickFormSelectModal.vue'
+import SpareBackFormSelectModal from '@/views/store/sparebackform/modules/SpareBackFormSelectModal'
+import DetailBaseForm from './DetailBaseForm'
+import StoreSelectModal from '@/views/store/store/modules/StoreSelectModal'
+import SpareStoreSelectModal from '@/views/store/sparestore/modules/SpareStoreSelectModalYY'
+import BaseFormForModify from '@/views/store/outstoredetail/modules/BaseFormForModify'
+import BaseTool from '@/utils/tool'
+import OutStoreFormSelectModal from './OutStoreFormSelectModal'
+import { queryUsersByParentDeptNatureAll } from '@/api/upms/user'
+import { fetchStoreTree } from '@/api/store/store'
+import { getSbPositions } from '@/api/repair/application-form'
+import { fetchSbTypeTree } from '@/api/project/project'
+
+export default {
+  name: 'BaseOutStoreFormYY',
+  components: {
+    DetailBaseForm,
+    SparePickFormSelectModal,
+    SpareBackFormSelectModal,
+    SpareStoreSelectModal,
+    StoreSelectModal,
+    OutStoreFormSelectModal,
+    BaseFormForModify
+  },
+  data () {
+    return {
+      confirmLoading: false,
+      modalTitle: null,
+      form: this.$form.createForm(this),
+      visible: false,
+      maskClosable: false,
+      outFlag: 1,
+      tokenType: 1,
+      model: {},
+
+      sbPositionList: [],
+      feeFromMap: {},
+      lyDeptMap: {},
+      flagMap: {},
+      sdDeptMap: {},
+      storeId: null,
+      treeData: [],
+      // 下拉框map
+      typeMap: {},
+      deptYYMap: {},
+      // 表头
+      columns: [
+        {
+          title: '序号',
+          dataIndex: 'index',
+          customRender: (text, record, index) => {
+            return index + 1
+          }
+        },
+        {
+          title: '名称',
+          dataIndex: 'spareName'
+        },
+        {
+          title: '编号',
+          dataIndex: 'no'
+        },
+        {
+          title: '规格',
+          dataIndex: 'ggxh'
+        },
+        {
+          title: '批次',
+          dataIndex: 'cbatch'
+        },
+        {
+          title: '数量',
+          dataIndex: 'num',
+          width: 150,
+          scopedSlots: { customRender: 'num' }
+        },
+        {
+          title: '单位',
+          dataIndex: 'unit'
+        },
+        {
+          title: '仓库',
+          dataIndex: 'storeName'
+        },
+        {
+          title: '货架号',
+          dataIndex: 'storePosition'
+        }
+      ],
+      data: [],
+      storeTreeDate: [],
+      userList: {},
+      user: this.$store.getters.userInfo,
+      selectedRowKeys: [],
+      selectedRows: [],
+      options: {
+        rowSelection: {
+          selectedRowKeys: this.selectedRowKeys
+        }
+      },
+      rowSelection: {
+        onChange: (selectedRowKeys, selectedRows) => {
+          this.selectedRowKeys = selectedRowKeys
+          this.selectedRows = selectedRows
+        }
+      }
+    }
+  },
+  props: {
+  },
+  created () {
+    this.setTree()
+    // 下拉框map
+    this.getSbPositions()
+    this.feeFromMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.FEE_FORM_TYPE)
+    this.lyDeptMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.DEPT_TYPE_LY)
+    this.sdDeptMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.DEPT_TYPE_SD)
+    this.flagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PROJECT_NEW_AND_OLD)
+    console.log(this.lyDeptMap)
+    console.log(this.sdDeptMap)
+    this.deptYYMap = this.DictCache.getChildrenList(this.DictCache.TYPE.OUT_STORE_FORM_DEPT_CODE).map(item => {
+      if (item.code === 'SBB') {
+        item.children = this.DictCache.getChildrenList(this.DictCache.TYPE.SBB)
+      }
+      return item
+    })
+
+    console.log(1, this.deptYYMap, 1)
+    // this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.OUT_STORE_FORM_TYPE)
+  },
+  methods: {
+    base (record, model) {
+      this.visible = true
+      this.model = model
+      this.outFlag = record.outFlag
+      if (record.outFlag === 1) {
+        this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.OUT_STORE_FORM_TYPE)
+      } else {
+        this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_BACK_FORM_TYPE)
+      }
+      const params = { deptId: this.user.companyId }
+      params.nature = this.DictCache.VALUE.SYS_DEPT_NATURE.FEN_GONG_SI
+      queryUsersByParentDeptNatureAll(params).then(res => {
+        this.userList = res.data
+      })
+      fetchStoreTree().then(res => {
+        this.storeTreeDate = res.data
+      })
+      // 如果是空标识添加
+      if (this.BaseTool.Object.isBlank(record.id)) {
+        this.modalTitle = '添加'
+        this.data = []
+        const { form: { setFieldsValue } } = this
+        // 日期处理
+        this.$nextTick(() => {
+          setFieldsValue(Object.assign(pick(record, [
+            'outFlag'
+          ]), pick(model, [
+            'sbCph'
+          ]), {
+            'sbPosition': model.sbPosition.split('->')
+
+          }))
+        })
+        return
+      }
+      this.modalTitle = '编辑'
+      const { form: { setFieldsValue } } = this
+      // 日期处理
+      this.storeId = record.storeId
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign(pick(record, [
+          'id',
+          'outNo',
+          'outStoreFormId',
+          'userId',
+          'applyDept',
+          'userTime',
+          'storeId',
+          'storeName',
+          'pickId',
+          'feeFrom',
+          'pickNo',
+          'type',
+          'remark'
+        ])))
+      })
+      this.data = record.detailList
+    },
+    setTree () {
+      fetchSbTypeTree({
+        flag: this.tokenType
+      }).then((res) => {
+        this.treeData = res.data.map(item => {
+          item.selectable = item.children == null
+          return item
+        })
+      })
+    },
+    save () {
+      const { form: { validateFieldsAndScroll } } = this
+      this.confirmLoading = true
+      validateFieldsAndScroll((errors, values) => {
+        if (errors) {
+          this.confirmLoading = false
+          return
+        }
+        if (this.data.length === 0) {
+          this.$message.error('请添加出库详情')
+          this.confirmLoading = false
+          return
+        }
+        values.detailList = this.data.filter(item => item.num > 0)
+        values.userTime = BaseTool.Date.formatter(values.userTime, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
+        // 日期处理
+        console.log(values)
+        addOutStoreBackFormYY(values)
+          .then(() => {
+            this.handleCancel(values)
+          }).catch(() => {
+            this.confirmLoading = false
+          })
+        // if (this.BaseTool.String.isBlank(values.id)) {
+        //   addOutStoreFormYY(values)
+        //     .then(() => {
+        //       this.handleCancel(values)
+        //     }).catch(() => {
+        //       this.confirmLoading = false
+        //     })
+        // } else {
+        //   updateOutStoreFormYY(values)
+        //     .then(() => {
+        //       this.handleCancel(values)
+        //     }).catch(() => {
+        //       this.confirmLoading = false
+        //     })
+        // }
+      })
+    },
+    loadData (selectedOptions) {
+      console.log(selectedOptions)
+      const targetOption = selectedOptions[selectedOptions.length - 1]
+      targetOption.loading = true
+      getSbPositions({ parentId: targetOption.id }).then(res => {
+        targetOption.loading = false
+        targetOption.children = res.data.map(item => {
+          item = {
+            label: item.name,
+            value: item.name
+          }
+          return item
+        })
+        this.sbPositionList = [...this.sbPositionList]
+      })
+    },
+    getSbPositions (parentId) {
+      getSbPositions({ parentId }).then(res => {
+        console.log(res)
+        this.sbPositionList = res.data.map(item => {
+          item = {
+            label: item.name,
+            value: item.name,
+            id: item.id,
+            isLeaf: false
+          }
+          return item
+        })
+      })
+    },
+    handleCancel (values) {
+      this.visible = false
+      this.confirmLoading = false
+      this.form.resetFields()
+      if (this.BaseTool.Object.isNotBlank(values)) {
+        this.$emit('ok', values)
+      } else {
+        this.$emit('ok')
+      }
+    },
+    typeChange (values) {
+      this.type = values
+    },
+    handleStoreSelect () {
+      this.$refs.storeSelectModal.base({}, { filter: -1 })
+    },
+    handleStoreSelected (record, keys, rows) {
+      // 重新选择了仓库,则明细需要全部清空
+      this.data = []
+      const [ key ] = keys
+      const [ row ] = rows
+      const { form: { setFieldsValue } } = this
+      this.storeId = key
+      // 日期处理
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign({
+          'storeId': key,
+          'storeName': row.name
+        }))
+      })
+    },
+    handleSparePickFormSelect () {
+      this.$refs.outStoreFormSelectModal.base()
+    },
+    handleOutStoreSelected (record, keys, rows) {
+      const [ key ] = keys
+      const [ row ] = rows
+      const { form: { setFieldsValue } } = this
+      // 日期处理
+      console.log(keys, rows)
+      fetchOutStoreForm({ id: key }).then(res => {
+        this.data = res.data.detailList.map(item => {
+          item.num = 0
+          return item
+        })
+      })
+      setFieldsValue(Object.assign({
+        'outStoreFormId': key,
+        'outNo': row.outNo
+      }))
+    },
+    handleSparePickFormSelected (record, keys, rows) {
+      const [ key ] = keys
+      const [ row ] = rows
+      const { form: { setFieldsValue } } = this
+      // 日期处理
+      setFieldsValue(Object.assign({
+        'pickId': key,
+        'pickNo': row.pickNo
+      }))
+    },
+    handleSpareBackFormSelected (record, keys, rows) {
+      const [ key ] = keys
+      const [ row ] = rows
+      const { form: { setFieldsValue } } = this
+      // 日期处理
+      setFieldsValue(Object.assign({
+        'pickId': key,
+        'pickNo': row.pickNo
+      }))
+    },
+    handleDetailSelect () {
+      if (this.storeId == null) {
+        this.$message.error('请先选择仓库')
+        return
+      }
+      this.$refs.detailBaseForm.base({ storeId: this.storeId })
+    },
+    handleDetailSelected (record) {
+      const { data } = this
+      data.push(record)
+    },
+    handleDel (id) {
+      const data = [...this.data]
+      if (this.selectedRowKeys.length === 0) {
+        this.$message.error('请至少选择一条数据')
+        return
+      }
+      this.data = data.filter(item => !this.selectedRowKeys.includes(item.id))
+    },
+    handleDelOne (record) {
+      const data = [...this.data]
+      this.data = data.filter(item => record.autoId !== item.autoId)
+    },
+    handleSpareStoreSelect () {
+      this.$refs.spareStoreSelectModal.base({ tokenType: this.tokenType })
+    },
+    handleSpareStoreSelected (record, keys, rows) {
+      console.log(rows)
+      const { data } = this
+      for (let i = 0; i < rows.length; i++) {
+        let find = false
+        for (let j = 0; j < data.length; j++) {
+          if (rows[i].autoId === data[j].autoId) {
+            find = true
+            break
+          }
+        }
+        if (!find) {
+          const selectData = rows[i]
+          selectData.storeNum = selectData.num
+          selectData.num = 1
+          data.push(selectData)
+        }
+      }
+    },
+    handleStoreChange (value) {
+      this.storeId = value
+    },
+    handleBaseFormForModifySelect (record) {
+      this.$refs.baseFormForModify.base(record)
+    },
+    handleBaseFormForModifySelected (values) {
+      console.log('values' + values.id)
+      const { data } = this
+      for (let j = 0; j < data.length; j++) {
+        if (values.id === data[j].id) {
+          data[j].num = values.num
+          data[j].totalPrice = values.totalPrice
+          break
+        }
+      }
+    },
+    onQuantityChange (e, autoId, attr) {
+      const value = e.target.value
+      console.log(value)
+      if (value !== 0 && !value) {
+        return
+      }
+      const data = [...this.data]
+      const target = data.find(item => item.autoId === autoId)
+      if (this.outFlag === 1 && value > target.storeNum) {
+        this.$message.error('领用数量不能大于库存数量')
+        target[attr] = 1
+        return
+      }
+      console.log('target: ' + target)
+      if (target) {
+        target[attr] = value
+        this.data = data
+      }
+    },
+    onTotalPriceChange (e, id, attr) {
+      const value = e.target.value
+      console.log(value)
+      if (value !== 0 && !value) {
+        return
+      }
+      const data = [...this.data]
+      const target = data.find(item => item.id === id)
+      console.log('target: ' + target)
+      if (target) {
+        target[attr] = value
+        this.data = data
+      }
+    }
+  }
+}
+</script>

+ 273 - 0
src/views/store/outstoreform/modules/OutStoreFormSelectModal copy.vue

@@ -0,0 +1,273 @@
+<template>
+  <a-modal
+    :title="modalTitle"
+    :width="1000"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    class="ant-modal2"
+    @cancel="handleCancel"
+  >
+    <a-card :bordered="false">
+      <div class="table-page-search-wrapper">
+        <a-form layout="inline">
+          <a-row :gutter="48">
+            <a-col :md="8" :sm="24">
+              <a-form-item label="关键字">
+                <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>
+              </a-form-item>
+            </a-col>
+            <a-col :md="8 || 24" :sm="24">
+              <span class="table-page-search-submitButtons">
+                <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
+                <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
+              </span>
+            </a-col>
+          </a-row>
+        </a-form>
+      </div>
+
+      <div class="table-operator" style="margin-bottom: 8px;">
+      </div>
+
+      <s-table
+        ref="table"
+        size="default"
+        rowKey="id"
+        :columns="columns"
+        :data="loadData"
+        :alert="options.alert"
+        :customRow="options.customRow"
+        :rowSelection="options.rowSelection"
+        showPagination="auto"
+      >
+        <span slot="action" slot-scope="record1">
+          <template>
+            <a @click="handleView(record1)">查看</a>
+          </template>
+        </span>
+      </s-table>
+      <detail ref="detailModal"/>
+    </a-card>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">取消</a-button>
+      <a-button :loading="confirmLoading" type="primary" @click="handleSelect()">选择</a-button>
+    </template>
+  </a-modal>
+</template>
+
+<script>
+import { STable, Ellipsis } from '@/components'
+import Detail from './Detail'
+import { getOutStoreFormPage, fetchOutStoreForm } from '@/api/store/outstoreform'
+
+export default {
+  name: 'OutStoreFormSelectModal',
+  components: {
+    STable,
+    Ellipsis,
+    Detail
+  },
+  props: {
+    type: {
+      type: String,
+      default: 'radio'
+    },
+    selectedRowKey: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    selectedRow: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    }
+  },
+  data () {
+    return {
+      confirmLoading: false,
+      mdl: {},
+      modalTitle: null,
+      visible: false,
+      record: null,
+      // 查询参数
+      queryParam: {
+      },
+      // 表头
+      columns: [
+        {
+          title: '序号',
+          dataIndex: 'index',
+          customRender: (text, record, index) => {
+            return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
+          }
+        },
+        {
+          title: '出库单号',
+          dataIndex: 'outNo'
+        },
+        {
+          title: '关联单id',
+          dataIndex: 'pickId'
+        },
+        {
+          title: '出库类型',
+          dataIndex: 'type',
+          customRender: (text, record, index) => {
+            return this.BaseTool.Object.getField(this.typeMap, text)
+          }
+        },
+        {
+          title: '关联单号',
+          dataIndex: 'pickNo'
+        },
+        {
+          title: '出库单号',
+          dataIndex: 'outNo'
+        },
+        {
+          title: '备注',
+          dataIndex: 'remark'
+        },
+        {
+          title: '创建日期',
+          dataIndex: 'createdTime'
+        },
+        {
+          title: '操作',
+          key: 'action',
+          width: '200px',
+          align: 'center',
+          scopedSlots: { customRender: 'action' }
+        }
+      ],
+      // 下拉框map
+      typeMap: {},
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        parameter = {
+          ...parameter,
+          ...this.queryParam,
+          dataScope: {
+            sortBy: 'desc',
+            sortName: 'update_time'
+          }
+        }
+        return getOutStoreFormPage(Object.assign(parameter, this.queryParam))
+          .then(res => {
+            return res.data
+          })
+      },
+      selectedRowKeys: [],
+      selectedRows: [],
+
+      options: {
+        alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
+        rowSelection: {
+          selectedRowKeys: this.selectedRowKeys,
+          onChange: this.onSelectChange
+        }
+      },
+      optionAlertShow: false,
+      isCreated: false
+    }
+  },
+  created () {
+    // 下拉框map
+    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.OUT_STORE_FORM_TYPE)
+  },
+  methods: {
+    tableOption () {
+      if (!this.optionAlertShow) {
+        this.options = {
+          alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
+          rowSelection: {
+            selectedRowKeys: this.selectedRowKeys,
+            onChange: this.onSelectChange,
+            type: this.type,
+            getCheckboxProps: record => ({
+              props: {
+                disabled: false,
+                name: record.id
+              }
+            })
+          },
+          customRow: (record) => {
+            return {
+              on: { // 事件
+                click: (event) => { // 点击行
+                  // 选择对象
+                  this.mySelect([record.id], [record])
+                },
+                dblclick: (event) => {
+                  this.mySelect([record.id], [record])
+                  this.handleSelect()
+                }
+              }
+            }
+          }
+        }
+        this.optionAlertShow = true
+      } else {
+        this.options = {
+          alert: false,
+          rowSelection: null
+        }
+        this.optionAlertShow = false
+      }
+    },
+    handleView (record) {
+      fetchOutStoreForm({ id: record.id }).then(res => {
+        const modal = this.$refs.detailModal
+        modal.base(res.data)
+      })
+    },
+    handleOk () {
+      this.$refs.table.refresh()
+    },
+    onSelectChange (selectedRowKeys, selectedRows) {
+      this.selectedRowKeys = selectedRowKeys
+      this.selectedRows = selectedRows
+    },
+    resetSearchForm () {
+      this.queryParam = {
+      }
+      this.$refs.table.refresh(true)
+    },
+    base (record, queryParam = {}) {
+      this.visible = true
+      this.modalTitle = '选择信息'
+      this.queryParam = queryParam
+      this.record = record
+      if (this.isCreated) {
+        this.$refs.table.clearSelected()
+        this.options.rowSelection.type = this.type
+        this.handleOk()
+      } else {
+        this.tableOption()
+        this.isCreated = true
+      }
+    },
+    handleCancel () {
+      this.visible = false
+      this.confirmLoading = false
+    },
+    handleSelect () {
+      if (this.selectedRowKeys.length === 0) {
+        this.$message.warn('请至少选择一项信息')
+      } else {
+        this.confirmLoading = true
+        this.$emit('selected', this.record, this.selectedRowKeys, this.selectedRows)
+        this.confirmLoading = false
+        this.visible = false
+      }
+    },
+    mySelect (selectedRowKeys, selectedRows) {
+      this.$refs.table.updateSelect(selectedRowKeys, selectedRows)
+      this.$refs.table.rowSelection.onChange(selectedRowKeys, selectedRows)
+    }
+  }
+}
+</script>

+ 11 - 17
src/views/store/outstoreform/modules/OutStoreFormSelectModal.vue

@@ -1,7 +1,7 @@
 <template>
   <a-modal
     :title="modalTitle"
-    :width="1000"
+    :width="1400"
     :visible="visible"
     :confirmLoading="confirmLoading"
     class="ant-modal2"
@@ -13,7 +13,7 @@
           <a-row :gutter="48">
             <a-col :md="8" :sm="24">
               <a-form-item label="关键字">
-                <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/类型名称"/>
+                <a-input v-model.trim="queryParam.keyword" placeholder="请输入维修工单/出库单号"/>
               </a-form-item>
             </a-col>
             <a-col :md="8 || 24" :sm="24">
@@ -109,23 +109,15 @@ export default {
           dataIndex: 'outNo'
         },
         {
-          title: '关联单id',
-          dataIndex: 'pickId'
-        },
-       {
-         title: '出库类型',
-         dataIndex: 'type',
-         customRender: (text, record, index) => {
-           return this.BaseTool.Object.getField(this.typeMap, text)
-         }
-       },
-       {
-          title: '关联单号',
-          dataIndex: 'pickNo'
+          title: '维修工单',
+          dataIndex: 'repairNo'
         },
         {
-          title: '出库单号',
-          dataIndex: 'outNo'
+          title: '出库类型',
+          dataIndex: 'type',
+          customRender: (text, record, index) => {
+            return this.BaseTool.Object.getField(this.typeMap, text)
+          }
         },
         {
           title: '备注',
@@ -151,6 +143,8 @@ export default {
           ...parameter,
           ...this.queryParam,
           dataScope: {
+            sortBy: 'desc',
+            sortName: 'update_time'
           }
         }
         return getOutStoreFormPage(Object.assign(parameter, this.queryParam))