فهرست منبع

Merge remote-tracking branch 'origin/xq'

13660505945 1 ماه پیش
والد
کامیت
faee7cdedc

+ 4 - 0
jshERP-web/src/components/jeecgbiz/modal/JSelectMaterialModal.vue

@@ -104,6 +104,7 @@
               </template>
             </a-row>
           </a-form>
+          <a-button type="primary" @click="findAllSelect">一键全选</a-button>
           <a-table
             ref="table"
             :scroll="scrollTrigger"
@@ -472,6 +473,9 @@ export default {
         },
       }
     },
+    findAllSelect() {
+      this.$emit('all', this.queryParam)
+    },
   },
 }
 </script>

+ 1 - 1
jshERP-web/src/mixins/JeecgListMixin.js

@@ -101,7 +101,7 @@ export const JeecgListMixin = {
       getAction(this.url.list, params).then((res) => {
         if (res.code === 200) {
           this.dataSource = res.data.rows
-          this.ipagination.total = res.data.total
+          this.ipagination.total = Number(res.data.total)
           this.tableAddTotalRow(this.columns, this.dataSource)
         } else if (res.code === 510) {
           this.$message.warning(res.data)

+ 79 - 0
jshERP-web/src/mixins/newTableMixin.js

@@ -0,0 +1,79 @@
+import Vue from 'vue'
+import { cloneDeep } from 'lodash'
+export const newTableMixin = {
+  data() {
+    return {
+      ipagination: {
+        current: 1,
+        pageSize: 2,
+        pageSizeOptions: ['2', '20', '30', '50', '100'],
+        showTotal: (total, range) => {
+          return range[0] + '-' + range[1] + ' 共' + total + '条'
+        },
+        showQuickJumper: true,
+        showSizeChanger: true,
+        total: 0,
+      },
+      /* table选中keys*/
+      selectedRowKeys: [],
+      /* table选中records*/
+      selectionRows: [],
+      /* 排序参数 */
+      isorter: {
+        column: 'createTime',
+        order: 'desc',
+      },
+      editableData: {},
+      // colList: ['categoryName', 'newPosition', 'differenceCount', 'differenceReason'],
+      colList: ['categoryName'],
+    }
+  },
+  methods: {
+    onSelectChange(selectedRowKeys, selectionRows) {
+      this.selectedRowKeys = selectedRowKeys
+      this.selectionRows = selectionRows
+    },
+    handleTableChange(pagination, filters, sorter) {
+      //分页、排序、筛选变化时触发
+      if (Object.keys(sorter).length > 0) {
+        if (sorter.order) {
+          this.isorter.column = sorter.field
+          this.isorter.order = 'ascend' === sorter.order ? 'asc' : 'desc'
+        } else {
+          this.isorter.column = 'createTime'
+          this.isorter.order = 'desc'
+        }
+      }
+      if (pagination && pagination.current) {
+        this.ipagination = pagination
+      }
+      this.getList()
+    },
+    formateTaskStatus(type) {
+      switch (type) {
+        case 1:
+          return '未开始'
+        case 2:
+          return '进行中'
+        case 3:
+          return '已完成'
+        case 4:
+          return '已取消'
+        default:
+          return ''
+      }
+    },
+    edit(id, col) {
+      this.editableData[id] = cloneDeep(this.dataSource.filter((item) => id === item.id)[0])
+      this.$forceUpdate()
+      console.log('111111111111111111111', col)
+    },
+    save(id) {
+      Object.assign(this.dataSource.filter((item) => id === item.id)[0], this.editableData[id])
+      delete this.editableData[id]
+    },
+    cancel(id) {
+      delete this.editableData[id]
+    },
+  },
+}

+ 207 - 0
jshERP-web/src/views/stock/CheckList.vue

@@ -0,0 +1,207 @@
+<template>
+  <a-row :gutter="24">
+    <a-col :md="24">
+      <a-card :bordered="false">
+        <!-- 查询区域 -->
+        <filter-form
+          @search="getList"
+          :queryParam="queryParam"
+          :spinnerList="spinnerList"
+          :deoptData="deoptData"
+        ></filter-form>
+        <div style="margin-bottom: 6px">
+          <a-button type="primary" icon="plus" @click="addTask('add')">开始盘点</a-button>
+
+          <!-- <a-popconfirm style="margin: 0 6px" title="确定取消选中的盘点任务吗?" @confirm="() => cancelTask()">
+            <a-button :disabled="!selectedRowKeys.length">取消盘点</a-button>
+          </a-popconfirm>
+          <a-popconfirm title="确定删除选中的盘点任务吗?" @confirm="() => handleDelete()">
+            <a-button :disabled="!selectedRowKeys.length">批量删除</a-button>
+          </a-popconfirm> -->
+          <!-- <a-button style="margin-left: 6px">导出任务</a-button> -->
+        </div>
+        <a-table
+          ref="table"
+          size="middle"
+          bordered
+          rowKey="id"
+          :columns="columns"
+          :dataSource="dataSource"
+          :pagination="ipagination"
+          :scroll="scroll"
+          :loading="loading"
+          :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
+          @change="handleTableChange"
+        >
+          <template slot="taskType" slot-scope="value">
+            {{ value === 1 ? '全盘' : '抽盘' }}
+          </template>
+          <template slot="taskStatus" slot-scope="value">
+            {{ formateTaskStatus(value) }}
+          </template>
+          <span slot="action" slot-scope="text, record">
+            <a @click="addTask('detail', record)">查看</a>
+            <a-divider type="vertical" />
+            <a @click="addTask('edit', record)">编辑</a>
+            <a-divider type="vertical" />
+            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
+              <a>删除</a>
+            </a-popconfirm>
+          </span>
+        </a-table>
+      </a-card>
+    </a-col>
+    <check-modal
+      :spinnerList="spinnerList"
+      :deoptData="deoptData"
+      :stockVisible.sync="stockVisible"
+      :title="title"
+      :rules="rules"
+      :taskId="taskId"
+      :openType="openType"
+      ref="stockF"
+    ></check-modal>
+  </a-row>
+</template>
+
+<script>
+// import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+import FilterForm from './components/FilterForm.vue'
+import table from './utils/table'
+// import StockModal from './components/stockModal.vue'
+import { getAction, postAction } from '@/api/manage'
+import { newTableMixin } from '@/mixins/newTableMixin'
+import CheckModal from './components/checkModal.vue'
+
+export default {
+  components: { FilterForm, CheckModal },
+  mixins: [newTableMixin],
+  data() {
+    return {
+      description: '盘点任务列表',
+      // 表头
+      scroll: { x: 1500 },
+      // 权限按钮集合
+      btnEnableList: [1, 1, 1],
+      queryParam: {
+        taskStatus: '',
+        number: '',
+        depotId: '',
+        createBy: '',
+      },
+      // stockTable: {
+      //   loading: false,
+      //   dataSource: [],
+      //   columns: table.taskColumns,
+      // },
+      columns: table.taskColumns,
+      dataSource: [],
+      loading: false,
+
+      rules: {
+        taskType: { rules: [{ required: true, message: '请选择盘点类型' }] },
+        depotId: { rules: [{ required: true, message: '请选择盘点仓库' }] },
+        taskName: { rules: [{ required: true, message: '请输入盘点任务名称' }] },
+      },
+
+      // rules: {
+      //   number: { rules: [{ required: true, message: '请输入盘点编号' }] },
+      // },
+
+      url: {
+        list: '/stocktaking/list',
+        add: '/stocktaking/add',
+        detailList: '/stocktaking/detail',
+        spinnerList: '/stocktaking/creatorSpinnerList',
+        depotList: '/depot/findDepotByCurrentUser',
+        detailByItemList: '/stocktaking/detailByItemList',
+        delete: '/stocktaking/taskDelete/',
+        cancel: '/stocktaking/taskCancel/',
+      },
+      stockVisible: false,
+      title: '',
+      spinnerList: [],
+      deoptData: [],
+      taskId: '',
+      openType: 'add',
+    }
+  },
+  watch: {
+    stockVisible(val) {
+      if (!val) {
+        this.getList()
+      }
+    },
+  },
+  created() {
+    this.getList()
+    this.getSpinnerList(), this.getDepotList()
+  },
+  methods: {
+    addTask(type, data) {
+      this.taskId = ''
+      this.openType = type
+      this.title = type === 'add' ? '新增' : type === 'edit' ? '编辑' : '查看'
+      if (type !== 'add') {
+        this.getDetailList(data.id)
+      }
+      this.stockVisible = true
+    },
+    getList(type) {
+      if (type === 'search') this.ipagination.current = 1 // 重新加载数据时,重置当前页为第一页
+      if (type === 'reset') {
+        for (let i in this.queryParam) {
+          this.$set(this.queryParam, i, null)
+        }
+      }
+      const url = this.url.list + '?pageNum=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
+      this.loading = true
+      const params = { ...this.queryParam }
+      postAction(url, params).then((res) => {
+        this.dataSource = res.data.rows
+        this.ipagination.total = Number(res.data.total)
+        this.loading = false
+      })
+    },
+    getDetailList(id) {
+      this.taskId = id
+    },
+
+    getSpinnerList() {
+      getAction(this.url.spinnerList).then((res) => {
+        this.spinnerList = res.data || []
+      })
+    },
+
+    getDepotList() {
+      getAction(this.url.depotList).then((res) => {
+        this.deoptData = res.data.map((item) => {
+          return {
+            label: item.depotName,
+            value: item.id,
+          }
+        })
+      })
+    },
+
+    handleDelete(id) {
+      const ids = id || this.selectedRowKeys
+      const url = this.url.delete + ids
+      getAction(url).then((res) => {
+        this.$message.success('删除成功')
+        this.getList()
+      })
+    },
+    cancelTask() {
+      const ids = this.selectedRowKeys
+      const url = this.url.cancel + ids
+      getAction(url).then((res) => {
+        this.$message.success('取消成功')
+        this.getList()
+      })
+    },
+  },
+}
+</script>
+
+<style></style>

+ 128 - 42
jshERP-web/src/views/stock/TaskList.vue

@@ -3,12 +3,22 @@
     <a-col :md="24">
       <a-card :bordered="false">
         <!-- 查询区域 -->
-        <!-- <filter-form></filter-form> -->
-        <div>
-          <a-button type="primary" icon="plus" @click="addTask">新增盘点任务</a-button>
-          <a-button>取消盘点</a-button>
-          <a-button>批量删除</a-button>
-          <a-button>导出任务</a-button>
+        <filter-form
+          @search="getList"
+          :queryParam="queryParam"
+          :spinnerList="spinnerList"
+          :deoptData="deoptData"
+        ></filter-form>
+        <div style="margin-bottom: 6px">
+          <a-button type="primary" icon="plus" @click="addTask('add')">新增盘点任务</a-button>
+
+          <a-popconfirm style="margin: 0 6px" title="确定取消选中的盘点任务吗?" @confirm="() => cancelTask()">
+            <a-button :disabled="!selectedRowKeys.length">取消盘点</a-button>
+          </a-popconfirm>
+          <a-popconfirm title="确定删除选中的盘点任务吗?" @confirm="() => handleDelete()">
+            <a-button :disabled="!selectedRowKeys.length">批量删除</a-button>
+          </a-popconfirm>
+          <!-- <a-button style="margin-left: 6px">导出任务</a-button> -->
         </div>
         <a-table
           ref="table"
@@ -17,23 +27,24 @@
           rowKey="id"
           :columns="columns"
           :dataSource="dataSource"
-          :components="handleDrag(columns)"
           :pagination="ipagination"
           :scroll="scroll"
           :loading="loading"
           :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
           @change="handleTableChange"
         >
+          <template slot="taskType" slot-scope="value">
+            {{ value === 1 ? '全盘' : '抽盘' }}
+          </template>
+          <template slot="taskStatus" slot-scope="value">
+            {{ formateTaskStatus(value) }}
+          </template>
           <span slot="action" slot-scope="text, record">
-            <a @click="myHandleDetail(record, '采购入库', prefixNo)">查看</a>
-            <a-divider v-if="btnEnableList.indexOf(1) > -1" type="vertical" />
-            <a v-if="btnEnableList.indexOf(1) > -1" @click="myHandleEdit(record)">编辑</a>
-            <a-divider v-if="btnEnableList.indexOf(1) > -1" type="vertical" />
-            <a-popconfirm
-              v-if="btnEnableList.indexOf(1) > -1"
-              title="确定删除吗?"
-              @confirm="() => myHandleDelete(record)"
-            >
+            <a @click="addTask('detail', record)">查看</a>
+            <a-divider type="vertical" />
+            <a @click="addTask('edit', record)">编辑</a>
+            <a-divider type="vertical" />
+            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
               <a>删除</a>
             </a-popconfirm>
           </span>
@@ -41,24 +52,29 @@
       </a-card>
     </a-col>
     <stock-modal
+      :spinnerList="spinnerList"
+      :deoptData="deoptData"
       :stockVisible.sync="stockVisible"
-      :form="form"
-      :validatorRules="validatorRules"
+      :title="title"
+      :rules="rules"
+      :taskId="taskId"
+      :openType="openType"
       ref="stockF"
     ></stock-modal>
   </a-row>
 </template>
 
 <script>
-import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+// import { JeecgListMixin } from '@/mixins/JeecgListMixin'
 import FilterForm from './components/FilterForm.vue'
 import table from './utils/table'
 import StockModal from './components/stockModal.vue'
-import { getAction } from '@/api/manage'
+import { getAction, postAction } from '@/api/manage'
+import { newTableMixin } from '@/mixins/newTableMixin'
 
 export default {
   components: { FilterForm, StockModal },
-  mixins: [JeecgListMixin],
+  mixins: [newTableMixin],
   data() {
     return {
       description: '盘点任务列表',
@@ -77,42 +93,112 @@ export default {
       //   dataSource: [],
       //   columns: table.taskColumns,
       // },
-      defColumns: table.taskColumns,
+      columns: table.taskColumns,
       dataSource: [],
-      form: {
-        number: '',
-        taskType: '',
-        taskName: '',
-        depotId: '',
-        creator: '',
-        createBy: '',
-        createTime: '',
-        positionRange: '',
-        materialExtendIdList: [],
-      },
-      validatorRules: {
+      loading: false,
+
+      rules: {
         taskType: { rules: [{ required: true, message: '请选择盘点类型' }] },
         depotId: { rules: [{ required: true, message: '请选择盘点仓库' }] },
         taskName: { rules: [{ required: true, message: '请输入盘点任务名称' }] },
       },
-      rules: {
-        number: { rules: [{ required: true, message: '请输入盘点编号' }] },
-      },
-      organId: { rules: [{ required: true, message: '请选择盘点类型' }] },
-      organId: { rules: [{ required: true, message: '请选择盘点仓库' }] },
-      organId: { rules: [{ required: true, message: '请选择盘点负责人' }] },
+
+      // rules: {
+      //   number: { rules: [{ required: true, message: '请输入盘点编号' }] },
+      // },
+
       url: {
         list: '/stocktaking/list',
         add: '/stocktaking/add',
+        detailList: '/stocktaking/detail',
+        spinnerList: '/stocktaking/creatorSpinnerList',
+        depotList: '/depot/findDepotByCurrentUser',
+        detailByItemList: '/stocktaking/detailByItemList',
+        delete: '/stocktaking/taskDelete/',
+        cancel: '/stocktaking/taskCancel/',
       },
       stockVisible: false,
+      title: '',
+      spinnerList: [],
+      deoptData: [],
+      taskId: '',
+      openType: 'add',
     }
   },
-
+  watch: {
+    stockVisible(val) {
+      if (!val) {
+        this.getList()
+      }
+    },
+  },
+  created() {
+    this.getList()
+    this.getSpinnerList(), this.getDepotList()
+  },
   methods: {
-    addTask() {
+    addTask(type, data) {
+      this.taskId = ''
+      this.openType = type
+      this.title = type === 'add' ? '新增盘点任务' : type === 'edit' ? '编辑盘点任务' : '查看盘点任务'
+      if (type !== 'add') {
+        this.getDetailList(data.id)
+      }
       this.stockVisible = true
     },
+    getList(type) {
+      if (type === 'search') this.ipagination.current = 1 // 重新加载数据时,重置当前页为第一页
+      if (type === 'reset') {
+        for (let i in this.queryParam) {
+          this.$set(this.queryParam, i, null)
+        }
+      }
+      const url = this.url.list + '?currentPage=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
+      this.loading = true
+      const params = { ...this.queryParam }
+      postAction(url, params).then((res) => {
+        this.dataSource = res.data.rows
+        this.ipagination.total = Number(res.data.total)
+        this.loading = false
+      })
+    },
+    getDetailList(id) {
+      this.taskId = id
+    },
+
+    getSpinnerList() {
+      getAction(this.url.spinnerList).then((res) => {
+        this.spinnerList = res.data || []
+      })
+    },
+
+    getDepotList() {
+      getAction(this.url.depotList).then((res) => {
+        this.deoptData = res.data.map((item) => {
+          return {
+            label: item.depotName,
+            value: item.id,
+          }
+        })
+      })
+    },
+
+    handleDelete(id) {
+      const ids = id || this.selectedRowKeys
+      const url = this.url.delete + ids
+      getAction(url).then((res) => {
+        this.$message.success('删除成功')
+        this.getList()
+      })
+    },
+    cancelTask() {
+      const ids = this.selectedRowKeys
+      const url = this.url.cancel + ids
+      getAction(url).then((res) => {
+        this.$message.success('取消成功')
+        this.getList()
+      })
+    },
   },
 }
 </script>

+ 48 - 19
jshERP-web/src/views/stock/components/FilterForm.vue

@@ -5,36 +5,24 @@
       <a-row :gutter="24">
         <a-col :md="6" :sm="24">
           <a-form-item label="盘点状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-select placeholder="请选择供应商" showSearch optionFilterProp="children" v-model="queryParam.taskStatus">
-              <a-select-option v-for="(item, index) in statusList" :key="index" :value="item.id">
-                {{ item.supplier }}
-              </a-select-option>
+            <a-select placeholder="请选择供应商" showSearch :options="taskStatusList" v-model="queryParam.taskStatus">
             </a-select>
           </a-form-item>
         </a-col>
         <a-col :md="6" :sm="24">
           <a-form-item label="盘点单号" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-input
-              placeholder="请输入条码、名称、助记码、规格、型号等信息"
-              v-model="queryParam.number"
-            ></a-input>
+            <a-input placeholder="请输入条码、名称、助记码、规格、型号等信息" v-model="queryParam.number"></a-input>
           </a-form-item>
         </a-col>
         <a-col :md="6" :sm="24">
           <a-form-item label="盘点仓库" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-select placeholder="请选择盘点仓库" showSearch optionFilterProp="children" v-model="queryParam.depotId">
-              <a-select-option v-for="(item, index) in statusList" :key="index" :value="item.id">
-                {{ item.supplier }}
-              </a-select-option>
+            <a-select placeholder="请选择盘点仓库" showSearch :options="spinnerList" v-model="queryParam.depotId">
             </a-select>
           </a-form-item>
         </a-col>
         <a-col :md="6" :sm="24">
           <a-form-item label="创建人" :labelCol="labelCol" :wrapperCol="wrapperCol">
-            <a-select placeholder="请选择创建人" showSearch optionFilterProp="children" v-model="queryParam.createBy">
-              <a-select-option v-for="(item, index) in statusList" :key="index" :value="item.id">
-                {{ item.supplier }}
-              </a-select-option>
+            <a-select placeholder="请选择创建人" showSearch :options="deoptData" v-model="queryParam.createBy">
             </a-select>
           </a-form-item>
         </a-col>
@@ -51,12 +39,12 @@
           <a-form-item label="商品信息" :labelCol="labelCol" :wrapperCol="wrapperCol">
             <a-input placeholder="请输入商品信息" v-model="queryParam.number"></a-input>
           </a-form-item>
-        </a-col>
+        </a-col> -->
         <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
           <a-col :md="6" :sm="24">
             <a-button type="primary" @click="searchQuery">查询</a-button>
             <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
-          </a-col> -->
+          </a-col>
         </span>
       </a-row>
     </a-form>
@@ -64,7 +52,48 @@
 </template>
 
 <script>
-export default {}
+export default {
+  props: {
+    queryParam: {
+      type: Object,
+      default: () => {},
+    },
+    spinnerList: {
+      type: Array,
+      default: () => [],
+    },
+    deoptData: {
+      type: Array,
+      default: () => [],
+    },
+  },
+  data() {
+    return {
+      labelCol: {
+        xs: { span: 24 },
+        sm: { span: 8 },
+      },
+      wrapperCol: {
+        xs: { span: 24 },
+        sm: { span: 16 },
+      },
+      taskStatusList: [
+        { value: 1, label: '未开始' },
+        { value: 2, label: '进行中' },
+        { value: 3, label: '已完成' },
+        { value: 4, label: '已取消' },
+      ],
+    }
+  },
+  methods: {
+    searchQuery() {
+      this.$emit('search', 'search')
+    },
+    searchReset() {
+      this.$emit('search', 'reset')
+    },
+  },
+}
 </script>
 
 <style></style>

+ 405 - 0
jshERP-web/src/views/stock/components/checkModal.vue

@@ -0,0 +1,405 @@
+<template>
+  <div>
+    <a-modal @cancel="handleCancel" :visible="stockVisible" :title="title" width="90%">
+      <a-spin :spinning="confirmLoading">
+        <edit-form
+          :spinnerList="spinnerList"
+          :depotList="deoptData"
+          :form="form"
+          :rules="rules"
+          :stockVisible="stockVisible"
+          ref="editForm"
+          :total="dataSource.length || 0"
+          openType="detail"
+          :stockType="stockType"
+          @getForm="getForm"
+          @clear="onClearList"
+        ></edit-form>
+        <a-divider />
+        <div>
+          <div>
+            <a-form :form="queryParams" ref="form">
+              <a-row class="form-row" :gutter="24">
+                <a-col :lg="6" :md="12" :sm="24" class="form-col">
+                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="商品类别">
+                    <!-- <a-input disabled placeholder="请输入" v-model="queryParams.categoryId" /> -->
+                    <a-tree-select
+                      style="width: 100%"
+                      :dropdownStyle="{ maxHeight: '200px', overflow: 'auto' }"
+                      allow-clear
+                      :treeData="categoryTree"
+                      v-model="queryParams.categoryId"
+                      placeholder="请选择商品类别"
+                    >
+                    </a-tree-select>
+                  </a-form-item>
+                </a-col>
+                <a-col :lg="6" :md="12" :sm="24" class="form-col">
+                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="商品名称">
+                    <a-input placeholder="请输入" v-model="queryParams.name" />
+                  </a-form-item>
+                </a-col>
+                <a-col :lg="6" :md="12" :sm="24" class="form-col">
+                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="批次号">
+                    <a-input placeholder="请输入" v-model="queryParams.batchNumber" />
+                  </a-form-item>
+                </a-col>
+                <a-col :lg="6" :md="12" :sm="24" class="form-col">
+                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="仓位货架">
+                    <a-input placeholder="请输入" v-model="queryParams.position" />
+                  </a-form-item>
+                </a-col>
+                <a-col :lg="6" :md="12" :sm="24" class="form-col">
+                  <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="是否存在数量差异">
+                    <a-select placeholder="请选择" v-model="form.isDifference" :options="isDifferenceData"> </a-select>
+                  </a-form-item>
+                </a-col>
+                <span>
+                  <a-col :md="6" :sm="24">
+                    <a-button type="primary" @click="getList">查询</a-button>
+                    <a-button style="margin-left: 8px" @click="getList">重置</a-button>
+                  </a-col>
+                </span>
+              </a-row>
+            </a-form>
+          </div>
+          <a-table
+            ref="table"
+            size="middle"
+            bordered
+            rowKey="id"
+            :columns="columns"
+            :dataSource="dataSource"
+            :pagination="ipagination"
+            :loading="loading"
+            @change="handleTableChange"
+          >
+            <!-- <template v-for="col in colList" :slot="col" slot-scope="text, record">
+              <div :key="col">
+                <a-input v-if="editableData[record.id]" v-model="editableData[record.id][col]" style="margin: -5px 0" />
+                <template v-else>
+                  {{ col }}
+                </template>
+              </div>
+            </template> -->
+            <span slot="action" v-if="openType !== 'detail'" slot-scope="text, record">
+              <a type="text" @click="handleEdit(record)">编辑</a>
+            </span>
+            <!-- <template slot="customName" slot-scope="text, record">
+          {{ record.name }}
+          <a-tag v-if="record.enableSerialNumber == 1" color="orange">序</a-tag>
+          <a-tag v-if="record.enableBatchNumber == 1" color="orange">批</a-tag>
+        </template> -->
+          </a-table>
+        </div>
+      </a-spin>
+      <template slot="footer">
+        <a-button @click="handleCancel">取消</a-button>
+        <a-button v-if="isShowBtn" @click="handleCancel">完成盘点</a-button>
+        <a-button v-if="isShowBtn" @click="handleOk" type="primary">确认更新盘点数据</a-button>
+      </template>
+    </a-modal>
+    <j-select-material-modal
+      @ok="getGoods"
+      @all="findAllSelect"
+      ref="selectModal"
+      :multi="true"
+    ></j-select-material-modal>
+    <a-modal @cancel="editVisible = false" @ok="onSubmitGoods" :visible="editVisible" title="编辑" width="50%">
+      <a-form :form="editForm">
+        <a-form-item label="盘点任务名称" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
+          <a-input disabled v-model="editForm.name" placeholder="请输入"></a-input>
+        </a-form-item>
+        <a-form-item label="批次号" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
+          <a-input disabled v-model="editForm.batchNumber" placeholder="请输入"></a-input>
+        </a-form-item>
+        <a-form-item label="实际库存" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
+          <a-input v-model="editForm.newInventory" placeholder="请输入"></a-input>
+        </a-form-item>
+        <a-form-item label="实际仓位货架" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
+          <a-input v-model="editForm.newPosition" placeholder="请输入"></a-input>
+        </a-form-item>
+        <a-form-item label="差异数量" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
+          <a-input v-model="editForm.differenceCount" placeholder="请输入"></a-input>
+        </a-form-item>
+        <a-form-item label="差异原因" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
+          <a-input v-model="editForm.differenceReason" placeholder="请输入"></a-input>
+        </a-form-item>
+      </a-form>
+    </a-modal>
+  </div>
+</template>
+
+<script>
+import { findBySelectOrgan, queryMaterialCategoryTreeList, getAllOrganizationTreeByUser } from '@/api/api'
+
+import editForm from './editForm.vue'
+import table from '../utils/table'
+import JSelectMaterialModal from '../../../components/jeecgbiz/modal/JSelectMaterialModal.vue'
+import { getAction, postAction } from '@/api/manage'
+import { getMaterialByBatchNumber } from '@/api/api'
+import { newTableMixin } from '@/mixins/newTableMixin'
+// import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+// import { Form } from 'ant-design-vue'
+// const useForm = Form.useForm
+export default {
+  components: { editForm, JSelectMaterialModal },
+  mixins: [newTableMixin],
+  props: {
+    rules: {
+      type: Object,
+      default: () => {
+        return {}
+      },
+    },
+
+    stockVisible: {
+      type: Boolean,
+      default: false,
+    },
+    title: {
+      type: String,
+      default: '新增',
+    },
+    spinnerList: {
+      type: Array,
+      default: () => [],
+    },
+    deoptData: {
+      type: Array,
+      default: () => [],
+    },
+    taskId: {
+      type: String,
+      default: '',
+    },
+    openType: {
+      type: String,
+      default: 'add',
+    },
+  },
+  data() {
+    return {
+      width: '1600px',
+      visible: false,
+      confirmLoading: false,
+      prefixNo: '',
+      loading: false,
+      dataSource: [],
+      columns: table.checkGoodsColumns,
+      url: {
+        add: '/stocktaking/add',
+        update: '/stocktaking/detailUpdate',
+        edit: '/stocktaking/itemUpdate',
+      },
+      form: {},
+      isShow: false,
+      stockType: 'check',
+      queryParams: { categoryId: '', materialName: '', batchNumber: '', position: '', isDifference: null },
+      isDifferenceData: [
+        {
+          label: '是',
+          value: '1',
+        },
+        {
+          label: '否',
+          value: '2',
+        },
+      ],
+      categoryTree: [],
+      labelCol: {
+        xs: { span: 24 },
+        sm: { span: 8 },
+      },
+      wrapperCol: {
+        xs: { span: 24 },
+        sm: { span: 16 },
+      },
+      editForm: {},
+      editVisible: false,
+    }
+  },
+  watch: {
+    stockVisible(val) {
+      this.loadCategoryTreeData()
+      if (val) {
+        if (this.taskId) {
+          this.$nextTick(() => {
+            this.getDetailList(this.taskId)
+          })
+
+          return
+        }
+      } else {
+        this.dataSource = []
+        this.ipagination.current = 1
+        this.loading = false
+      }
+    },
+    editVisible(val) {
+      if (!val) {
+        this.editForm = {}
+        this.form.resetFields()
+      }
+    },
+  },
+  computed: {
+    isShowBtn() {
+      return this.openType !== 'detail' || this.form.taskStatus !== 1
+    },
+  },
+  methods: {
+    handleEdit(data) {
+      this.editForm = { ...data }
+      this.editVisible = true
+    },
+    onSubmitGoods() {
+      postAction(this.url.edit, this.editForm).then((res) => {
+        this.$message.success('操作成功')
+        this.editVisible = false
+      })
+    },
+    loadCategoryTreeData() {
+      let params = {}
+      params.id = ''
+      queryMaterialCategoryTreeList(params).then((res) => {
+        if (res) {
+          this.categoryTree = []
+          for (let i = 0; i < res.length; i++) {
+            let temp = res[i]
+            this.categoryTree.push(temp)
+          }
+        }
+      })
+    },
+    handleCancel() {
+      this.$emit('update:stockVisible', false)
+    },
+    handleOk() {
+      this.$refs.editForm.form.validateFields((err, values) => {
+        if (!err) {
+          const params = { ...values }
+          if (params.taskType === 2) {
+            params.materialExtendIdList = this.dataSource.map((item) => item.batchNumber)
+          }
+          const url = this.openType === 'add' ? this.url.add : this.url.update
+          postAction(url, params).then((res) => {
+            this.$message.success('操作成功')
+            this.handleCancel()
+          })
+        }
+      })
+    },
+    onChangeGoods() {
+      this.$refs.selectModal.queryParam.depotId = this.form.depotId
+      this.$refs.selectModal.showModal()
+    },
+    getDetailList(id) {
+      const url = '/stocktaking/detail/' + id
+      const form = this.$refs['editForm'].form
+
+      getAction(url).then((res) => {
+        const {
+          depotId,
+          taskName,
+          taskStatus,
+          taskType,
+          createTime,
+          createByName,
+          materialCount,
+          positionRange,
+          creator,
+          id,
+          operBy,
+          operTime,
+        } = res.data
+        form.setFieldsValue({
+          depotId,
+          taskName,
+          taskStatus,
+          taskType,
+          createTime,
+          createByName,
+          materialCount,
+          positionRange,
+          creator,
+          id,
+          operBy,
+          operTime,
+        })
+        this.getList(id)
+      })
+    },
+    getList(id) {
+      const url2 = '/stocktaking/detailByItemList'
+
+      const params = { ...this.queryParams, taskStocktakingId: id }
+      const url = url2 + '?pageNum=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
+      postAction(url, params).then((res) => {
+        this.dataSource = res.data
+        this.ipagination.total = this.dataSource.length
+        const materialExtendIdList = this.dataSource.map((item) => item.batchNumber)
+
+        form.setFieldsValue({
+          materialExtendIdList,
+        })
+        this.getForm(form.getFieldsValue())
+      })
+    },
+    getGoods(rows, ids) {
+      const str = ids
+        .split(',')
+        .filter((item) => item)
+        .join(',')
+      this.getBatchData(str)
+    },
+    findAllSelect() {
+      const params = { ...this.$refs.selectModal.queryParam }
+      getAction('/material/findBatchNumbersBySelect', params).then((res) => {
+        this.$refs.selectModal.close()
+        this.getBatchData(res.data)
+      })
+    },
+    getBatchData(val) {
+      const batchStr = val
+        .split(',')
+        .filter((item) => item)
+        .join(',')
+      const params = {
+        batchNumber: batchStr,
+        organId: '',
+        mpList: '',
+        prefixNo: '',
+      }
+      getMaterialByBatchNumber(params).then((res) => {
+        this.dataSource.push(...res.data)
+        this.dataSource = this.dataSource.reduce((acc, cur) => {
+          const hasDuplicate = acc.some((item) => item.batchNumber === cur.batchNumber)
+          if (!hasDuplicate) {
+            acc.push(cur)
+          }
+          return acc
+        }, [])
+      })
+    },
+    getForm(val) {
+      this.form = val
+      this.$refs['editForm'].model = val
+    },
+    //删除
+    handleDelete(record) {
+      this.dataSource = this.dataSource.filter((item) => item.batchNumber !== record.batchNumber)
+    },
+
+    onClearList(val) {
+      this.dataSource = []
+      this.getForm(val)
+      if (val.taskType === 1) {
+        this.findAllSelect()
+      }
+    },
+  },
+}
+</script>
+
+<style></style>

+ 123 - 34
jshERP-web/src/views/stock/components/editForm.vue

@@ -1,80 +1,102 @@
 <template>
-  <a-form :model="form">
+  <a-form :form="form" ref="form">
     <a-row class="form-row" :gutter="24">
       <a-col :lg="6" :md="12" :sm="24" class="form-col">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点单号">
-          <a-input placeholder="请输入" v-model="form.number" />
+          <a-input disabled placeholder="请输入" v-decorator="['number']" />
         </a-form-item>
       </a-col>
       <a-col :lg="6" :md="12" :sm="24" class="form-col">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点类型">
-          <a-select placeholder="请选择" v-model="form.taskType" :options="taskTypeList"> </a-select>
+          <a-select
+            placeholder="请选择"
+            @change="handleTaskType"
+            v-decorator="['taskType', rules.taskType]"
+            :options="taskTypeList"
+            :disabled="isDisabled"
+          >
+          </a-select>
         </a-form-item>
       </a-col>
       <a-col :lg="6" :md="12" :sm="24" class="form-col">
-        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点任务名称">
-          <a-input placeholder="请输入" v-model="form.taskName" />
+        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" required prop="taskName" label="盘点任务名称">
+          <a-input placeholder="请输入" :disabled="isDisabled" v-decorator="['taskName', rules.taskName]" />
         </a-form-item>
       </a-col>
       <a-col :lg="6" :md="12" :sm="24" class="form-col">
-        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点仓库">
-          <a-select placeholder="请选择" v-model="form.depotId" :options="depotList"> </a-select>
+        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="depotId" label="盘点仓库">
+          <a-select
+            placeholder="请选择"
+            v-decorator="['depotId', rules.depotId]"
+            :options="depotList"
+            :disabled="isDisabled"
+            @change="exportForm"
+          >
+          </a-select>
         </a-form-item>
       </a-col>
       <a-col :lg="6" :md="12" :sm="24" class="form-col">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点负责人">
-          <a-select placeholder="请选择" v-model="form.creator" :options="spinnerList"> </a-select>
+          <a-select placeholder="请选择" v-decorator="['creator']" :options="spinnerList" :disabled="isDisabled">
+          </a-select>
         </a-form-item>
       </a-col>
       <a-col :lg="6" :md="12" :sm="24" class="form-col">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="创建人">
-          <a-input placeholder="请输入" disabled v-model="form.createBy" />
+          <a-input placeholder="请输入" v-decorator="['createByName']" disabled />
         </a-form-item>
       </a-col>
       <a-col :lg="6" :md="12" :sm="24" class="form-col">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="创建时间">
-          <a-input placeholder="请输入" disabled v-model="form.createTime" />
+          <a-input placeholder="请输入" disabled v-decorator="['createTime']" />
         </a-form-item>
       </a-col>
       <a-col :lg="6" :md="12" :sm="24" class="form-col">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点库位范围">
-          <a-input placeholder="请输入" v-model="form.positionRange" />
+          <a-input placeholder="请输入" v-decorator="['positionRange']" disabled />
         </a-form-item>
       </a-col>
       <a-col :lg="6" :md="12" :sm="24" class="form-col">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="商品数量">
-          <a-input placeholder="请输入" v-model="form.materialCount" />
+          <a-input disabled placeholder="请输入" v-decorator="['materialCount']" />
         </a-form-item>
       </a-col>
-      <a-col :lg="6" :md="12" :sm="24" class="form-col">
-        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点状态">
-          <!-- <a-input placeholder="请输入" v-model="form.taskStatus" /> -->
-          <a-select placeholder="请选择" v-model="form.taskStatus" :options="taskStatusList"> </a-select>
-        </a-form-item>
-      </a-col>
-      <!-- <a-col :lg="6" :md="12" :sm="24" class="form-col">
+      <a-col v-if="stockType === 'check'" :lg="6" :md="12" :sm="24" class="form-col">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点人">
-          <a-input placeholder="请输入" v-decorator.trim="['number']" />
+          <a-input placeholder="请输入" disabled v-decorator.trim="['operBy']" />
         </a-form-item>
       </a-col>
-      <a-col :lg="6" :md="12" :sm="24" class="form-col">
+      <a-col v-if="stockType === 'check'" :lg="6" :md="12" :sm="24" class="form-col">
         <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="完成时间">
-          <a-input placeholder="请输入" v-decorator.trim="['number']" />
+          <a-input placeholder="请输入" disabled v-decorator.trim="['operTime']" />
+        </a-form-item>
+      </a-col>
+      <a-col v-show="false" :lg="6" :md="12" :sm="24" class="form-col">
+        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点状态">
+          <a-select placeholder="请选择" v-decorator="['taskStatus']" :options="taskStatusList" :disabled="isDisabled">
+          </a-select>
+        </a-form-item>
+      </a-col>
+      <a-col v-show="false" :lg="6" :md="12" :sm="24" class="form-col">
+        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="盘点状态">
+          <a-input v-decorator="['id']"></a-input>
         </a-form-item>
-      </a-col> -->
+      </a-col>
     </a-row>
   </a-form>
 </template>
 
 <script>
+import pick from 'lodash.pick'
+
 export default {
   name: 'EditForm',
   props: {
-    form: {
-      type: Object,
-      default: null,
-    },
-    validatorRules: {
+    // form: {
+    //   type: Object,
+    //   default: null,
+    // },
+    rules: {
       type: Object,
       default: () => {
         return {}
@@ -92,9 +114,31 @@ export default {
         return []
       },
     },
+    stockVisible: {
+      type: Boolean,
+      default: false,
+    },
+    total: {
+      type: [Number, String],
+      default: 0,
+    },
+    openType: {
+      type: String,
+      default: 'add',
+    },
+    stockType: {
+      type: String,
+      default: '',
+    },
   },
   data() {
     return {
+      taskStatusList: [
+        { value: 1, label: '未开始' },
+        { value: 2, label: '进行中' },
+        { value: 3, label: '已完成' },
+        { value: 4, label: '已取消' },
+      ],
       labelCol: {
         xs: { span: 24 },
         sm: { span: 8 },
@@ -107,14 +151,59 @@ export default {
         { value: 1, label: '全盘' },
         { value: 2, label: '抽盘' },
       ],
-      taskStatusList: [
-        { value: 0, label: '未开始' },
-        { value: 1, label: '进行中' },
-        { value: 2, label: '已完成' },
-        { value: 3, label: '已取消' },
-      ],
+
+      validatorRules: {},
+      model: {},
+      form: this.$form.createForm(this),
     }
   },
+  watch: {
+    model: {
+      handler(val) {
+        console.log('=====================222', this.form.getFieldsValue())
+      },
+      deep: true,
+      immediate: true,
+    },
+    total(val) {
+      this.form.setFieldsValue({ materialCount: val })
+    },
+    // 监听弹窗显示隐藏,重置表单数据
+    stockVisible: {
+      handler(val) {
+        if (!val) {
+          this.form.resetFields()
+          this.exportForm()
+        }
+        if (this.openType === 'add') {
+          this.model.taskStatus = 1
+
+          this.$nextTick(() => {
+            this.form.setFieldsValue({ taskStatus: 1 })
+          })
+        }
+      },
+      immediate: true,
+      deep: true,
+    },
+  },
+  computed: {
+    isDisabled() {
+      return this.openType === 'detail' || this.model.taskStatus !== 1
+    },
+  },
+  methods: {
+    exportForm() {
+      this.$nextTick(() => {
+        this.$emit('getForm', this.form.getFieldsValue())
+      })
+    },
+    handleTaskType() {
+      this.$nextTick(() => {
+        this.$emit('clear', this.form.getFieldsValue())
+      })
+    },
+  },
 }
 </script>
 

+ 178 - 68
jshERP-web/src/views/stock/components/stockModal.vue

@@ -1,23 +1,26 @@
 <template>
   <div>
-    <a-modal
-      :visible="stockVisible"
-      :title="title"
-      @ok="handleOk"
-      @cancel="handleCancel"
-      width="90%"
-      wrapClassName="full-modal"
-    >
+    <a-modal @cancel="handleCancel" :visible="stockVisible" :title="title" width="90%">
       <a-spin :spinning="confirmLoading">
         <edit-form
           :spinnerList="spinnerList"
           :depotList="deoptData"
           :form="form"
-          :validatorRules="validatorRules"
+          :rules="rules"
+          :stockVisible="stockVisible"
+          ref="editForm"
+          :total="dataSource.length || 0"
+          :openType="openType"
+          :stockType="stockType"
+          @getForm="getForm"
+          @clear="onClearList"
         ></edit-form>
-        <div v-if="form.taskType === 2">
-          <a-button style="margin-bottom: 6px" type="primary" @click="onChangeGoods">选择商品</a-button>
+        <div>
+          <a-button v-if="form.taskType === 2" style="margin-bottom: 6px" type="primary" @click="onChangeGoods"
+            >选择商品</a-button
+          >
           <a-table
+            v-if="dataSource.length"
             ref="table"
             size="middle"
             bordered
@@ -29,15 +32,13 @@
             :loading="loading"
             @change="handleTableChange"
           >
-            <!-- <span slot="action" slot-scope="text, record">
-          <a>查看</a>
-          <a>编辑</a>
-          <a-divider v-if="btnEnableList.indexOf(1) > -1" type="vertical" />
-          <a-popconfirm title="确定删除吗?">
-            <a>删除</a>
-          </a-popconfirm>
-        </span>
-        <template slot="customName" slot-scope="text, record">
+            <span v-if="form.taskType === 2" slot="action" slot-scope="text, record">
+              <a-divider type="vertical" />
+              <a-popconfirm @confirm="handleDelete(record)" title="确定删除吗?">
+                <a>删除</a>
+              </a-popconfirm>
+            </span>
+            <!-- <template slot="customName" slot-scope="text, record">
           {{ record.name }}
           <a-tag v-if="record.enableSerialNumber == 1" color="orange">序</a-tag>
           <a-tag v-if="record.enableBatchNumber == 1" color="orange">批</a-tag>
@@ -45,8 +46,17 @@
           </a-table>
         </div>
       </a-spin>
+      <template slot="footer">
+        <a-button @click="handleCancel">取消</a-button>
+        <a-button v-if="isShowBtn" @click="handleOk" type="primary">确认发布盘点任务</a-button>
+      </template>
     </a-modal>
-    <j-select-material-modal @ok="getGoods" ref="selectModal" :multi="true"></j-select-material-modal>
+    <j-select-material-modal
+      @ok="getGoods"
+      @all="findAllSelect"
+      ref="selectModal"
+      :multi="true"
+    ></j-select-material-modal>
   </div>
 </template>
 
@@ -55,20 +65,22 @@ import editForm from './editForm.vue'
 import table from '../utils/table'
 import JSelectMaterialModal from '../../../components/jeecgbiz/modal/JSelectMaterialModal.vue'
 import { getAction, postAction } from '@/api/manage'
-
+import { getMaterialByBatchNumber } from '@/api/api'
+import { newTableMixin } from '@/mixins/newTableMixin'
+// import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+// import { Form } from 'ant-design-vue'
+// const useForm = Form.useForm
 export default {
   components: { editForm, JSelectMaterialModal },
+  mixins: [newTableMixin],
   props: {
-    form: {
-      type: Object,
-      default: null,
-    },
-    validatorRules: {
+    rules: {
       type: Object,
       default: () => {
         return {}
       },
     },
+
     stockVisible: {
       type: Boolean,
       default: false,
@@ -77,46 +89,61 @@ export default {
       type: String,
       default: '新增',
     },
+    spinnerList: {
+      type: Array,
+      default: () => [],
+    },
+    deoptData: {
+      type: Array,
+      default: () => [],
+    },
+    taskId: {
+      type: String,
+      default: '',
+    },
+    openType: {
+      type: String,
+      default: 'add',
+    },
   },
   data() {
     return {
-      //   validatorRules: {
-      //     organId: { rules: [{ required: true, message: '请选择盘点类型' }] },
-      //     organId: { rules: [{ required: true, message: '请选择盘点仓库' }] },
-      //     organId: { rules: [{ required: true, message: '请选择盘点负责人' }] },
-      //   },
       width: '1600px',
       visible: false,
       confirmLoading: false,
       prefixNo: '',
-      //   form: {},
-
       loading: false,
       dataSource: [],
       columns: table.goodsColums,
       url: {
-        spinnerList: '/stocktaking/creatorSpinnerList',
-        depotList: '/depot/findDepotByCurrentUser',
         add: '/stocktaking/add',
+        update: '/stocktaking/detailUpdate',
       },
-      spinnerList: [],
-      deoptData: [],
+      form: {},
+      isShow: false,
+      stockType: 'task',
     }
   },
   watch: {
     stockVisible(val) {
       if (val) {
-        this.getSpinnerList()
-        this.getDepotList()
+        if (this.taskId) {
+          this.$nextTick(() => {
+            this.getDetailList(this.taskId)
+          })
+
+          return
+        }
+      } else {
+        this.dataSource = []
+        this.ipagination.current = 1
+        this.loading = false
       }
     },
-    form: {
-      handler(val) {
-        if (val.taskType === 1) {
-          val.materialExtendIdList = []
-        }
-      },
-      deep: true,
+  },
+  computed: {
+    isShowBtn() {
+      return this.openType !== 'detail' || this.form.taskStatus !== 1
     },
   },
   methods: {
@@ -124,40 +151,123 @@ export default {
       this.$emit('update:stockVisible', false)
     },
     handleOk() {
-      postAction(this.url.add, this.form).then((res) => {
-        console.log('222222222222222222222', res)
-
-        // this.$emit('ok')
+      this.$refs.editForm.form.validateFields((err, values) => {
+        if (!err) {
+          const params = { ...values }
+          if (params.taskType === 2) {
+            params.materialExtendIdList = this.dataSource.map((item) => item.batchNumber)
+          }
+          const url = this.openType === 'add' ? this.url.add : this.url.update
+          postAction(url, params).then((res) => {
+            this.$message.success('操作成功')
+            this.handleCancel()
+          })
+        }
       })
     },
     onChangeGoods() {
+      this.$refs.selectModal.queryParam.depotId = this.form.depotId
       this.$refs.selectModal.showModal()
     },
-    getSpinnerList() {
-      getAction(this.url.spinnerList).then((res) => {
-        this.spinnerList = res.data || []
-      })
-    },
+    getDetailList(id) {
+      const url = '/stocktaking/detail/' + id
+      const url2 = '/stocktaking/detailByItemList'
+      const form = this.$refs['editForm'].form
 
-    getDepotList() {
-      getAction(this.url.depotList).then((res) => {
-        this.deoptData = res.data.map((item) => {
-          return {
-            label: item.depotName,
-            value: item.id,
-          }
+      getAction(url).then((res) => {
+        const {
+          depotId,
+          taskName,
+          taskStatus,
+          taskType,
+          createTime,
+          createByName,
+          materialCount,
+          positionRange,
+          creator,
+          id,
+        } = res.data
+        form.setFieldsValue({
+          depotId,
+          taskName,
+          taskStatus,
+          taskType,
+          createTime,
+          createByName,
+          materialCount,
+          positionRange,
+          creator,
+          id,
+        })
+
+        postAction(url2, { taskStocktakingId: id }).then((res) => {
+          this.dataSource = res.data
+          this.ipagination.total = this.dataSource.length
+          const materialExtendIdList = this.dataSource.map((item) => item.batchNumber)
+
+          form.setFieldsValue({
+            materialExtendIdList,
+          })
+          this.getForm(form.getFieldsValue())
         })
       })
     },
     getGoods(rows, ids) {
-      this.form.materialExtendIdList = ids.split(',').filter((item) => item)
-      this.dataSource = rows
+      const str = ids
+        .split(',')
+        .filter((item) => item)
+        .join(',')
+      this.getBatchData(str)
+    },
+    findAllSelect() {
+      const params = { ...this.$refs.selectModal.queryParam }
+      getAction('/material/findBatchNumbersBySelect', params).then((res) => {
+        this.$refs.selectModal.close()
+        this.getBatchData(res.data)
+      })
+    },
+    getBatchData(val) {
+      const batchStr = val
+        .split(',')
+        .filter((item) => item)
+        .join(',')
+      const params = {
+        batchNumber: batchStr,
+        organId: '',
+        mpList: '',
+        prefixNo: '',
+      }
+      getMaterialByBatchNumber(params).then((res) => {
+        this.dataSource.push(...res.data)
+        this.dataSource = this.dataSource.reduce((acc, cur) => {
+          const hasDuplicate = acc.some((item) => item.batchNumber === cur.batchNumber)
+          if (!hasDuplicate) {
+            acc.push(cur)
+          }
+          return acc
+        }, [])
+      })
+    },
+    getForm(val) {
+      this.form = val
+      this.$refs['editForm'].model = val
+    },
+    //删除
+    handleDelete(record) {
+      this.dataSource = this.dataSource.filter((item) => item.batchNumber !== record.batchNumber)
+    },
+
+    onClearList(val) {
+      this.dataSource = []
+      this.getForm(val)
+      if (val.taskType === 1) {
+        this.findAllSelect()
+      }
     },
 
     handleDrag() {},
-    ipagination() {},
-    selectedRowKeys() {},
-    onSelectChange() {},
+    // ipagination() {},
+
     handleTableChange() {},
   },
 }

+ 40 - 12
jshERP-web/src/views/stock/utils/table.js

@@ -7,48 +7,50 @@ const table = {
     },
     {
       title: '盘点任务编号',
-      dataIndex: 'num',
+      dataIndex: 'number',
     },
 
     {
       title: '盘点任务名称',
-      dataIndex: 'name',
+      dataIndex: 'taskName',
     },
     {
       title: '盘点类型',
-      dataIndex: 'type',
+      dataIndex: 'taskType',
+      scopedSlots: { customRender: 'taskType' },
     },
     {
       title: '盘点仓库',
-      dataIndex: 'num',
+      dataIndex: 'depotName',
     },
     {
       title: '商品数量',
-      dataIndex: 'time',
+      dataIndex: 'materialCount',
     },
     {
       title: '盘点库位范围',
-      dataIndex: 'status',
+      dataIndex: 'positionRange',
     },
     {
       title: '创建人',
-      dataIndex: 'person',
+      dataIndex: 'createByName',
     },
     {
       title: '创建时间',
-      dataIndex: 'status',
+      dataIndex: 'createTime',
     },
     {
       title: '盘点负责人',
-      dataIndex: 'person',
+      dataIndex: 'creatorName',
     },
     {
       title: '盘点状态',
-      dataIndex: 'remark',
+      dataIndex: 'taskStatus',
+      scopedSlots: { customRender: 'taskStatus' },
     },
     {
       title: '完成时间',
-      dataIndex: 'remark',
+      dataIndex: 'operTime',
     },
   ],
   goodsColums: [
@@ -56,9 +58,11 @@ const table = {
       title: '操作',
       dataIndex: 'action',
       align: 'center',
-      width: 60,
+      width: 90,
       scopedSlots: { customRender: 'action' },
     },
+    { dataIndex: 'id', title: 'id' },
+
     // { dataIndex: 'mBarCode', title: '条码', scopedSlots: { customRender: 'customBarCode' } },
     { dataIndex: 'batchNumber', title: '批次号' },
     { dataIndex: 'name', title: '名称', scopedSlots: { customRender: 'customName' } },
@@ -77,6 +81,30 @@ const table = {
     { dataIndex: 'depotId', title: '仓库名称' },
     { dataIndex: 'position', title: '仓库货架' },
   ],
+  checkGoodsColumns: [
+    { dataIndex: 'categoryName', title: '商品类别', scopedSlots: { customRender: 'categoryName' } },
+    { dataIndex: 'name', title: '商品名称' },
+    { dataIndex: 'systemSku', title: '系统SKU' },
+    { dataIndex: 'batchNumber', title: '批次号' },
+    { dataIndex: 'unit', title: '单位' },
+    { dataIndex: 'productionDate', title: '生产日期' },
+    { dataIndex: 'supplierName', title: '供应商' },
+    { dataIndex: 'barCode', title: '商品条码' },
+    { dataIndex: 'stock', title: '库存(最小单位)' },
+    { dataIndex: 'depotId', title: '仓库名称' },
+    { dataIndex: 'position', title: '仓库货架' },
+    { dataIndex: 'newInventory', title: '实际库存' },
+    { dataIndex: 'newPosition', title: '实际仓位货架' },
+    { dataIndex: 'differenceCount', title: '差异数量' },
+    { dataIndex: 'differenceReason', title: '差异原因' },
+    {
+      title: '操作',
+      dataIndex: 'action',
+      align: 'center',
+      width: 90,
+      scopedSlots: { customRender: 'action' },
+    },
+  ],
 }
 
 export default table