Pārlūkot izejas kodu

Merge branch 'demo_' of http://123.60.19.203:8088/hitch/hitch-antd into demo_

408249787 2 gadi atpakaļ
vecāks
revīzija
7e44b82012

+ 1 - 0
src/router/generator-platform-routers.js

@@ -145,6 +145,7 @@ const constantRouterComponents = {
   'InStoreForm': () => import('@/views/store/instoreform/InStoreForm'),
   // 出库登记单
   'OutStoreForm': () => import('@/views/store/outstoreform/OutStoreForm'),
+  'OutStoreFormYY': () => import('@/views/store/outstoreform/OutStoreFormYY'),
   // 调拨登记单
   'TransferStoreForm': () => import('@/views/store/transferstoreform/TransferStoreForm'),
 

+ 0 - 1
src/views/store/outstoreform/OutStoreForm.vue

@@ -61,7 +61,6 @@
             <a @click="handleView(record)">查看</a>
             <a-divider v-if="record.status==1" type="vertical" />
             <a v-if="$auth('store-out-store-forms-edit')&&record.status==1" @click="handleEdit(record)">修改</a>
-
             <a-divider v-if="record.status==1" type="vertical" />
             <a-popconfirm v-if="record.status==1" title="是否要出库,出库将更新库存?" @confirm="updateStore(record.id)">
               <a>出库</a>

+ 305 - 0
src/views/store/outstoreform/OutStoreFormYY.vue

@@ -0,0 +1,305 @@
+<template>
+  <a-card :bordered="false">
+    <div v-show="visible">
+      <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
+        <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" :sm="24">
+              <a-form-item label="出库类型">
+                <a-select v-model="queryParam.type" placeholder="请选择">
+                  <a-select-option
+                    v-for="(label,value) in typeMap"
+                    :key="value"
+                    :label="label"
+                    :value="parseInt(value)">{{ label }}
+                  </a-select-option>
+                </a-select>
+              </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;">
+        <a-button v-if="$auth('store-out-store-forms-add')" type="primary" icon="plus" @click="handleAdd()">新增</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">
+            <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
+              <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
+            </a-popconfirm>
+          </a-menu>
+          <a-button style="margin-left: 8px">
+            批量操作 <a-icon type="down" />
+          </a-button>
+        </a-dropdown>-->
+      </div>
+
+      <s-table
+        ref="table"
+        size="default"
+        rowKey="id"
+        :columns="columns"
+        :data="loadData"
+        :alert="options.alert"
+        :rowSelection="options.rowSelection"
+        showPagination="auto"
+      >
+        <span slot="action" slot-scope="record">
+          <template>
+            <a @click="handleView(record)">查看</a>
+            <a-divider v-if="record.status==1" type="vertical" />
+            <a v-if="$auth('store-out-store-forms-edit')&&record.status==1" @click="handleEdit(record)">修改</a>
+            <a-divider v-if="record.status==1" type="vertical" />
+            <a-popconfirm v-if="record.status==1" title="是否要出库,出库将更新库存?" @confirm="updateStore(record.id)">
+              <a>出库</a>
+            </a-popconfirm>
+            <a-divider v-if="record.status==1" type="vertical" />
+            <a-popconfirm v-if="$auth('store-out-store-forms-del')&&record.status==1" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">
+              <a>删除</a>
+            </a-popconfirm>
+            <a-divider v-if="record.status==2" type="vertical" />
+            <a-popconfirm v-if="record.status==2" title="是否要撤销?" @confirm="updateStoreBack(record.id)">
+              <a>撤销</a>
+            </a-popconfirm>
+          </template>
+        </span>
+        <span slot="status" slot-scope="text">
+          <badge
+            :status="DictCache.COLOR.OUT_STORE_FORM_STATUS[text]"
+            :text="statusMap[text]" />
+        </span>
+      </s-table>
+    </div>
+    <detail ref="detailModal" @ok="handleOk"/>
+    <base-form ref="baseModal" @ok="handleOk"/>
+  </a-card>
+</template>
+
+<script>
+import { STable, Ellipsis } from '@/components'
+import BaseForm from './modules/BaseFormYY'
+import Detail from './modules/Detail'
+import { updateStore, updateStoreBack, getOutStoreFormPage, deleteOutStoreForms, fetchOutStoreForm, exportOutStoreForm } from '@/api/store/outstoreform'
+import { fetchInStoreForm } from '@/api/store/instoreform'
+
+export default {
+  name: 'OutStoreFormList',
+  components: {
+    STable,
+    Ellipsis,
+    BaseForm,
+    Detail
+  },
+  props: {
+    filter: {
+      type: Number,
+      default: -1
+    }
+  },
+  data () {
+    return {
+      // 查询参数
+      queryParam: {
+        filter: this.filter,
+        ...this.$route.query
+
+      },
+      // 表头
+      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: '出库类型',
+          dataIndex: 'type',
+          customRender: (text, record, index) => {
+            return this.BaseTool.Object.getField(this.typeMap, text)
+          }
+        },
+        {
+          title: '总价',
+          dataIndex: 'totalPrice'
+        },
+        {
+          title: '状态',
+          dataIndex: 'status',
+          scopedSlots: { customRender: 'status' }
+        },
+        {
+          title: '创建日期',
+          dataIndex: 'createdTime'
+        },
+        {
+          title: '仓库',
+          dataIndex: 'storeId',
+          customRender: (text, record, index) => {
+            return record.storeName
+          }
+        },
+        {
+          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: [],
+      visible: true,
+      options: {
+        alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
+        rowSelection: {
+          selectedRowKeys: this.selectedRowKeys,
+          onChange: this.onSelectChange
+        }
+      },
+      optionAlertShow: false
+    }
+  },
+  created () {
+    // 下拉框map
+    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.OUT_STORE_FORM_TYPE)
+    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.OUT_STORE_FORM_STATUS)
+    this.tableOption()
+  },
+  methods: {
+    tableOption () {
+      if (!this.optionAlertShow) {
+        this.options = {
+          alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
+          rowSelection: {
+            selectedRowKeys: this.selectedRowKeys,
+            onChange: this.onSelectChange,
+            getCheckboxProps: record => ({
+              props: {
+                disabled: false,
+                name: record.id
+              }
+            })
+          }
+        }
+        this.optionAlertShow = true
+      } else {
+        this.options = {
+          alert: false,
+          rowSelection: null
+        }
+        this.optionAlertShow = false
+      }
+    },
+    batchDelete (id) {
+      let ids = []
+      if (this.BaseTool.String.isBlank(id)) {
+        const length = this.selectedRows.length
+        if (length === 0) {
+          this.$message.info('请选择要删除的记录')
+          return
+        }
+        ids = this.selectedRows.map(item => item.id)
+      } else {
+        ids = [id]
+      }
+      deleteOutStoreForms(ids).then(res => {
+        this.$message.info('删除成功')
+        this.handleOk()
+        this.$refs.table.clearSelected()
+      })
+    },
+    handleView (record) {
+      this.visible = false
+      fetchOutStoreForm({ id: record.id }).then(res => {
+        const modal = this.$refs.detailModal
+        modal.base(res.data)
+      })
+    },
+    handleAdd () {
+      this.visible = false
+      const modal = this.$refs.baseModal
+      modal.base()
+    },
+    handleEdit (record) {
+      this.visible = false
+      fetchOutStoreForm({ id: record.id }).then(res => {
+        const modal = this.$refs.baseModal
+        res.data.storeName = record.storeName
+        modal.base(res.data)
+      })
+    },
+    updateStore (id) {
+      updateStore({ id: id }).then(res => {
+        this.$message.info('出库成功')
+        this.$refs.table.refresh()
+      })
+    },
+    updateStoreBack (id) {
+      updateStoreBack({ id: id }).then(res => {
+        this.$message.info('撤销成功')
+        this.$refs.table.refresh()
+      })
+    },
+    handleOk () {
+      this.visible = true
+      this.$refs.table.refresh()
+    },
+    onSelectChange (selectedRowKeys, selectedRows) {
+      this.selectedRowKeys = selectedRowKeys
+      this.selectedRows = selectedRows
+    },
+    resetSearchForm () {
+      this.queryParam = {
+        filter: this.filter
+      }
+      this.$refs.table.refresh(true)
+    },
+    doExport () {
+      const parameter = {
+        ...this.queryParam
+      }
+      exportOutStoreForm(parameter).then(file => {
+        this.BaseTool.UPLOAD.downLoadExportExcel(file)
+      })
+    },
+    handleEnter () {
+      this.$refs.table.refresh(true)
+    }
+  }
+}
+</script>

+ 506 - 0
src/views/store/outstoreform/modules/BaseFormYY.vue

@@ -0,0 +1,506 @@
+<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-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
+              v-decorator="['outNo', {rules: [{required: false, message: '出库单号不能为空'}]}]" />
+          </a-form-item>
+        </a-col>
+<!--        <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="['pickNo']"/>
+            <a-button type="primary" style="width: 30%" @click="handleSparePickFormSelect">选择</a-button>
+          </a-form-item>
+        </a-col>
+        <a-col :lg="12" :md="24" :sm="24">
+          <a-form-item
+            label="仓库"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-tree-select
+              style="width: 100%"
+              @change="handleStoreChange"
+              :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
+              :treeData="storeTreeDate"
+              :treeNodeFilterProp="'title'"
+              :showSearch="true"
+              v-decorator="['storeId', {rules: [{required: false, message: '仓库不能为空'}]}]"
+              placeholder="请选择"
+            >
+            </a-tree-select>
+          </a-form-item>
+        </a-col>-->
+        <a-col :lg="12" :md="24" :sm="24">
+          <a-form-item
+            label="出库类型"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-select @change="typeChange" v-decorator="['type', {initValue: 1, rules: [{required: true, message: '出库类型不能为空'}]}]" placeholder="请选择">
+              <a-select-option
+                v-for="(label,value) in typeMap"
+                :key="value"
+                :label="label"
+                :value="parseInt(value)">{{ label }}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+<!--        <a-col :lg="12" :md="24" :sm="24">
+          <a-form-item
+            label="操作人"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-select v-decorator="['userId']" placeholder="请选择">
+              <a-select-option
+                v-for="({userId, realName}) in userList"
+                :key="userId"
+                :label="realName"
+                :value="userId">{{ realName }}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>-->
+        <a-col :lg="12" :md="24" :sm="24">
+          <a-form-item
+            label="操作时间"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-date-picker
+              style="width: 100%"
+              :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
+              v-decorator="['userTime', {rules: [{required: true, message: '操作时间不能为空'}]}]" />
+          </a-form-item>
+        </a-col>
+        <a-col :lg="12" :md="24" :sm="24">
+          <a-form-item
+            label="备注"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-textarea
+              :rows="4"
+              v-decorator="['remark', {rules: [{required: false, message: '备注不能为空'}]}]"/>
+          </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="id"
+      :row-selection="rowSelection">
+      <template slot="num" slot-scope="text, record">
+        <div class="editable-cell-input-wrapper">
+          <a-input :value="text" :id="record.spareId + ',num'" @change="$event => onQuantityChange($event, record.id, 'num')" />
+        </div>
+      </template>
+      <template slot="totalPrice" slot-scope="text, record">
+        <div class="editable-cell-input-wrapper">
+          <a-input :value="text" :id="record.spareId + ',totalPrice'" @change="$event => onTotalPriceChange($event, record.id, 'totalPrice')" />
+        </div>
+      </template>
+      <span slot="action" slot-scope="record">
+        <template>
+          <a @click="handleBaseFormForModifySelect(record)">修改</a>
+          <a-divider type="vertical" />
+          <a-popconfirm title="是否要删除该条数据?" @confirm="handleDelOne(record.id)">
+            <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 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"/>
+  </a-card>
+</template>
+
+<script>
+import pick from 'lodash.pick'
+import { addOutStoreForm, updateOutStoreForm } from '@/api/store/outstoreform'
+import SparePickFormSelectModal from '@/views/store/sparepickform/modules/SparePickFormSelectModal'
+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 { queryUsersByParentDeptNatureAll } from '@/api/upms/user'
+import { fetchStoreTree } from '@/api/store/store'
+
+export default {
+  name: 'BaseOutStoreForm',
+  components: {
+    DetailBaseForm,
+    SparePickFormSelectModal,
+    SpareBackFormSelectModal,
+    SpareStoreSelectModal,
+    StoreSelectModal,
+    BaseFormForModify
+  },
+  data () {
+    return {
+      confirmLoading: false,
+      modalTitle: null,
+      form: this.$form.createForm(this),
+      visible: false,
+      maskClosable: false,
+      type: 1,
+      storeId: null,
+      // 下拉框map
+      typeMap: {},
+      // 表头
+      columns: [
+        {
+          title: '序号',
+          dataIndex: 'index',
+          customRender: (text, record, index) => {
+            return index + 1
+          }
+        },
+        {
+          title: '名称',
+          dataIndex: 'spareId',
+          customRender: (text, record, index) => {
+            return record.spareName
+          }
+        },
+        {
+          title: '编号',
+          dataIndex: 'no'
+        },
+        {
+          title: '规格',
+          dataIndex: 'ggxh'
+        },
+        {
+          title: '原厂编号',
+          dataIndex: 'initNo'
+        },
+        {
+          title: '数量',
+          dataIndex: 'num',
+          width: 150,
+          scopedSlots: { customRender: 'num' }
+        },
+        {
+          title: '价格',
+          dataIndex: 'price',
+          customRender: (text, record, index) => {
+            return this.BaseTool.Amount.formatter(text)
+          }
+        },
+        {
+          title: '总价',
+          dataIndex: 'totalPrice',
+          customRender: (text, record, index) => {
+            return this.BaseTool.Amount.formatter(text)
+          }
+        },
+        {
+          title: '所在仓库',
+          dataIndex: 'storeName'
+        },
+        {
+          title: '操作',
+          key: 'action',
+          align: 'center',
+          scopedSlots: { customRender: 'action' }
+        }
+      ],
+      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 () {
+    // 下拉框map
+    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.OUT_STORE_FORM_TYPE)
+  },
+  methods: {
+    base (record) {
+      this.visible = true
+      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)) {
+        this.modalTitle = '添加'
+        this.data = []
+        return
+      }
+      this.modalTitle = '编辑'
+      const { form: { setFieldsValue } } = this
+      // 日期处理
+      this.storeId = record.storeId
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign(pick(record, [
+          'id',
+          'outNo',
+          'userId',
+          'userTime',
+          'storeId',
+          'storeName',
+          'pickId',
+          'pickNo',
+          'type',
+          'remark'
+        ])))
+      })
+      this.data = record.detailList
+    },
+    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
+        values.userTime = BaseTool.Date.formatter(values.userTime, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
+        // 日期处理
+        if (this.BaseTool.String.isBlank(values.id)) {
+          addOutStoreForm(values)
+            .then(() => {
+              this.handleCancel(values)
+            }).catch(() => {
+              this.confirmLoading = false
+            })
+        } else {
+          updateOutStoreForm(values)
+            .then(() => {
+              this.handleCancel(values)
+            }).catch(() => {
+              this.confirmLoading = false
+            })
+        }
+      })
+    },
+
+    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 () {
+      if (this.type === 1) {
+        this.$refs.sparePickFormSelectModal.base()
+      } else {
+        this.$refs.spareBackFormSelectModal.base()
+      }
+    },
+    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 (id) {
+      const data = [...this.data]
+      this.data = data.filter(item => id !== item.id)
+    },
+    handleSpareStoreSelect () {
+      this.$refs.spareStoreSelectModal.base({}, { num: 0 })
+    },
+    handleSpareStoreSelected (record, keys, 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].id === data[j].id || rows[i].spareId === data[j].spareId) {
+            find = true
+            break
+          }
+        }
+        if (!find) {
+          const selectData = rows[i]
+          selectData.num = 1
+          selectData.totalPrice = selectData.price
+          selectData.storeId = rows[i].storeId
+          selectData.storeName = rows[i].storeName
+          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, 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
+        target['totalPrice'] = Math.floor(value * target['price'] * 10000) / 10000
+        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>

+ 367 - 0
src/views/store/sparestore/modules/SpareStoreSelectModalYY.vue

@@ -0,0 +1,367 @@
+<template>
+  <a-modal
+    :title="modalTitle"
+    :width="1050"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    class="ant-modal2"
+    @cancel="handleCancel"
+  >
+    <a-card :bordered="false">
+      <a-row :gutter="8">
+        <!--        <a-col :span="5">
+          <a-tree
+            @expand="onExpand"
+            :expandedKeys="expandedKeys"
+            :autoExpandParent="true"
+            @select="onSelect"
+            :selectedKeys="selectedKeys"
+            :treeData="spareTypeTreeData"
+          />
+        </a-col>-->
+        <a-col :span="24">
+          <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" :sm="24">
+                  <a-form-item label="类型">
+                    <a-tree-select
+                      style="width: 100%"
+                      :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
+                      :treeData="spareTypeTreeData"
+                      :treeNodeFilterProp="'title'"
+                      :showSearch="true"
+                      v-model="queryParam.typeId"
+                      placeholder="请选择"
+                    >
+                    </a-tree-select>
+                  </a-form-item>
+                </a-col>
+                <a-col :md="8" :sm="24">
+                  <a-form-item label="规格型号">
+                    <a-input v-model="queryParam.ggxh" placeholder="模糊查询"/>
+                  </a-form-item>
+                </a-col>
+                <a-col :md="8" :sm="24">
+                  <a-form-item label="原厂编号">
+                    <a-input v-model="queryParam.initNo" placeholder="模糊查询"/>
+                  </a-form-item>
+                </a-col>
+                <a-col :md="8" :sm="24">
+                  <a-form-item label="关联设备">
+                    <a-input v-model="queryParam.model" placeholder="新号/旧号/名称/规格"/>
+                  </a-form-item>
+                </a-col>
+                <a-col :md="8" :sm="24">
+                  <a-form-item
+                    label="仓库"
+                    :labelCol="BaseTool.Constant.labelCol"
+                    :wrapperCol="BaseTool.Constant.wrapperCol"
+                  >
+                    <a-tree-select
+                      style="width: 100%"
+                      :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
+                      :treeData="storeTreeDate"
+                      :treeNodeFilterProp="'title'"
+                      :showSearch="true"
+                      v-model="queryParam.storeId"
+                      placeholder="请选择"
+                    >
+                    </a-tree-select>
+                  </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"
+          >
+          </s-table>
+        </a-col>
+      </a-row>
+      <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 { fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
+import { fetchStoreTree } from '@/api/store/store'
+
+import { getSparePageYY } from '@/api/yongyou/yongyou'
+export default {
+  name: 'SpareStoreSelectModalYY',
+  components: {
+    STable,
+    Ellipsis,
+    Detail
+  },
+  props: {
+    type: {
+      type: String,
+      default: 'checkbox'
+    },
+    selectedRowKey: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    selectedRow: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    }
+  },
+  data () {
+    return {
+      confirmLoading: false,
+      mdl: {},
+      storeTreeDate: [],
+      modalTitle: null,
+      visible: false,
+      record: null,
+      spareTypeTreeData: [],
+      expandedKeys: [],
+      selectedKeys: [],
+      isSpecial: 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: '备件id',
+        //  dataIndex: 'spareId'
+        // },
+        {
+          title: '备件编号',
+          dataIndex: 'no'
+        },
+        {
+          title: '备件名称',
+          dataIndex: 'spareName'
+        },
+        {
+          title: '规格型号',
+          dataIndex: 'ggxh'
+        },
+        {
+          title: '原厂编号',
+          dataIndex: 'initNo'
+        },
+        {
+          title: '仓库名称',
+          dataIndex: 'storeName'
+        },
+        {
+          title: '库存数量',
+          dataIndex: 'num'
+        },
+        {
+          title: '价格',
+          dataIndex: 'price'
+        },
+        {
+          title: '单位',
+          dataIndex: 'unit'
+        },
+        {
+          title: '操作',
+          key: 'action',
+          align: 'center',
+          scopedSlots: { customRender: 'action' }
+        }
+      ],
+      // 下拉框map
+      delFlagMap: {},
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        parameter = {
+          ...parameter,
+          ...this.queryParam,
+          dataScope: {
+            sortBy: 'desc',
+            sortName: 'update_time'
+          }
+        }
+        return getSparePageYY(Object.assign(parameter, this.queryParam)).then(res => {
+          if (res.data.rows === null) {
+            const data = { total: 0, rows: [], pageNum: 1, pageSize: 10, pages: 1 }
+            return data
+          } else {
+            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.delFlagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.DELFLAG)
+    // this.tableOption()
+    fetchSpareTypeTree({}).then(res => {
+      this.spareTypeTreeData = res.data
+    })
+    fetchStoreTree({}).then(res => {
+      this.storeTreeDate = res.data
+    })
+  },
+  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
+      }
+    },
+    handleOk () {
+      this.$refs.table.refresh()
+    },
+    onSelectChange (selectedRowKeys, selectedRows) {
+      this.selectedRowKeys = selectedRowKeys
+      this.selectedRows = selectedRows
+    },
+    resetSearchForm () {
+      this.queryParam.keyword = null
+      this.queryParam.typeId = null
+      this.queryParam.model = null
+      this.queryParam.storeId = null
+      this.$refs.table.refresh(true)
+    },
+    base (record, queryParam = {}) {
+      this.visible = true
+      this.modalTitle = '选择信息'
+      this.queryParam = queryParam
+      if (queryParam.isSpecial !== undefined) {
+        this.isSpecial = queryParam.isSpecial
+        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 {
+        /* console.log(this.selectedRows[0].num)
+         if (this.selectedRows[0].num == 0) {
+         this.$message.error('不能选择库存为0的物品,请重新选择')
+         return
+       } */
+        this.confirmLoading = true
+        if (this.record !== null) {
+          this.record.isSpecial = this.isSpecial
+        }
+        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)
+    },
+    onSelect: function (selectedKeys, info) {
+      this.selectedKeys = selectedKeys
+      this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
+      this.$refs.table.refresh(true)
+    },
+    onExpand (expandedKeys) {
+      this.expandedKeys = expandedKeys
+      this.autoExpandParent = false
+    }
+  }
+}
+</script>