checkModal.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <div>
  3. <a-modal @cancel="handleCancel" :visible="stockVisible" :title="title" width="90%">
  4. <a-spin :spinning="confirmLoading">
  5. <edit-form
  6. :spinnerList="spinnerList"
  7. :depotList="deoptData"
  8. :form="form"
  9. :rules="rules"
  10. :stockVisible="stockVisible"
  11. ref="editForm"
  12. :total="dataSource.length || 0"
  13. openType="detail"
  14. :stockType="stockType"
  15. @getForm="getForm"
  16. @clear="onClearList"
  17. ></edit-form>
  18. <a-divider />
  19. <div>
  20. <div>
  21. <a-form :form="queryParams" ref="form">
  22. <a-row class="form-row" :gutter="24">
  23. <a-col :lg="6" :md="12" :sm="24" class="form-col">
  24. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="商品类别">
  25. <!-- <a-input disabled placeholder="请输入" v-model="queryParams.categoryId" /> -->
  26. <a-tree-select
  27. style="width: 100%"
  28. :dropdownStyle="{ maxHeight: '200px', overflow: 'auto' }"
  29. allow-clear
  30. :treeData="categoryTree"
  31. v-model="queryParams.categoryId"
  32. placeholder="请选择商品类别"
  33. >
  34. </a-tree-select>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :lg="6" :md="12" :sm="24" class="form-col">
  38. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="商品名称">
  39. <a-input placeholder="请输入" v-model="queryParams.name" />
  40. </a-form-item>
  41. </a-col>
  42. <a-col :lg="6" :md="12" :sm="24" class="form-col">
  43. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="批次号">
  44. <a-input placeholder="请输入" v-model="queryParams.batchNumber" />
  45. </a-form-item>
  46. </a-col>
  47. <a-col :lg="6" :md="12" :sm="24" class="form-col">
  48. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="仓位货架">
  49. <a-input placeholder="请输入" v-model="queryParams.position" />
  50. </a-form-item>
  51. </a-col>
  52. <a-col :lg="6" :md="12" :sm="24" class="form-col">
  53. <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="是否存在数量差异">
  54. <a-select placeholder="请选择" v-model="form.isDifference" :options="isDifferenceData"> </a-select>
  55. </a-form-item>
  56. </a-col>
  57. <span>
  58. <a-col :md="6" :sm="24">
  59. <a-button type="primary" @click="onSearch">查询</a-button>
  60. <a-button style="margin-left: 8px" @click="onReset">重置</a-button>
  61. </a-col>
  62. </span>
  63. </a-row>
  64. </a-form>
  65. </div>
  66. <a-table
  67. ref="table"
  68. size="middle"
  69. bordered
  70. rowKey="id"
  71. :columns="columns"
  72. :dataSource="dataSource"
  73. :pagination="ipagination"
  74. :loading="loading"
  75. @change="handleTableChange"
  76. >
  77. <!-- <template v-for="col in colList" :slot="col" slot-scope="text, record">
  78. <div :key="col">
  79. <a-input v-if="editableData[record.id]" v-model="editableData[record.id][col]" style="margin: -5px 0" />
  80. <template v-else>
  81. {{ col }}
  82. </template>
  83. </div>
  84. </template> -->
  85. <span slot="action" v-if="openType !== 'detail'" slot-scope="text, record">
  86. <a type="text" @click="handleEdit(record)">编辑</a>
  87. </span>
  88. <!-- <template slot="customName" slot-scope="text, record">
  89. {{ record.name }}
  90. <a-tag v-if="record.enableSerialNumber == 1" color="orange">序</a-tag>
  91. <a-tag v-if="record.enableBatchNumber == 1" color="orange">批</a-tag>
  92. </template> -->
  93. </a-table>
  94. </div>
  95. </a-spin>
  96. <template slot="footer">
  97. <a-button @click="handleCancel">取消</a-button>
  98. <a-button v-if="isShowBtn" @click="handleOk">完成盘点</a-button>
  99. <a-button v-if="isShowBtn" @click="handleUpdate" type="primary">确定更新盘点数据</a-button>
  100. </template>
  101. </a-modal>
  102. <j-select-material-modal
  103. @ok="getGoods"
  104. @all="findAllSelect"
  105. ref="selectModal"
  106. :multi="true"
  107. ></j-select-material-modal>
  108. <a-modal @cancel="editVisible = false" @ok="onSubmitGoods" :visible="editVisible" title="编辑" width="50%">
  109. <a-form :form="editForm">
  110. <a-form-item label="盘点任务名称" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
  111. <a-input disabled v-model="editForm.name" placeholder="请输入"></a-input>
  112. </a-form-item>
  113. <a-form-item label="批次号" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
  114. <a-input disabled v-model="editForm.batchNumber" placeholder="请输入"></a-input>
  115. </a-form-item>
  116. <a-form-item label="实际库存" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
  117. <a-input v-model="editForm.newInventory" placeholder="请输入"></a-input>
  118. </a-form-item>
  119. <a-form-item label="实际仓位货架" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
  120. <a-input v-model="editForm.newPosition" placeholder="请输入"></a-input>
  121. </a-form-item>
  122. <a-form-item label="差异数量" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
  123. <a-input v-model="editForm.differenceCount" placeholder="请输入"></a-input>
  124. </a-form-item>
  125. <a-form-item label="差异原因" :labelCol="{ span: 4 }" :wrapperCol="{ span: 14 }">
  126. <a-input v-model="editForm.differenceReason" placeholder="请输入"></a-input>
  127. </a-form-item>
  128. </a-form>
  129. </a-modal>
  130. </div>
  131. </template>
  132. <script>
  133. import { findBySelectOrgan, queryMaterialCategoryTreeList, getAllOrganizationTreeByUser } from '@/api/api'
  134. import editForm from './editForm.vue'
  135. import table from '../utils/table'
  136. import JSelectMaterialModal from '../../../components/jeecgbiz/modal/JSelectMaterialModal.vue'
  137. import { getAction, postAction } from '@/api/manage'
  138. import { getMaterialByBatchNumber } from '@/api/api'
  139. import { newTableMixin } from '@/mixins/newTableMixin'
  140. import { Modal } from 'ant-design-vue'
  141. // import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  142. // import { Form } from 'ant-design-vue'
  143. // const useForm = Form.useForm
  144. export default {
  145. components: { editForm, JSelectMaterialModal },
  146. mixins: [newTableMixin],
  147. props: {
  148. rules: {
  149. type: Object,
  150. default: () => {
  151. return {}
  152. },
  153. },
  154. stockVisible: {
  155. type: Boolean,
  156. default: false,
  157. },
  158. title: {
  159. type: String,
  160. default: '新增',
  161. },
  162. spinnerList: {
  163. type: Array,
  164. default: () => [],
  165. },
  166. deoptData: {
  167. type: Array,
  168. default: () => [],
  169. },
  170. taskId: {
  171. type: String,
  172. default: '',
  173. },
  174. openType: {
  175. type: String,
  176. default: 'add',
  177. },
  178. },
  179. data() {
  180. return {
  181. width: '1600px',
  182. visible: false,
  183. confirmLoading: false,
  184. prefixNo: '',
  185. loading: false,
  186. dataSource: [],
  187. columns: table.checkGoodsColumns,
  188. url: {
  189. add: '/stocktaking/add',
  190. update: '/stocktaking/detailUpdate',
  191. edit: '/stocktaking/itemUpdate',
  192. updateStock: '/stocktaking/taskUpdateStock/',
  193. taskCom: ' /stocktaking/taskComplete/',
  194. detail: '/stocktaking/detail/',
  195. },
  196. form: {},
  197. isShow: false,
  198. stockType: 'check',
  199. queryParams: { categoryId: '', materialName: '', batchNumber: '', position: '', isDifference: null },
  200. isDifferenceData: [
  201. {
  202. label: '是',
  203. value: '1',
  204. },
  205. {
  206. label: '否',
  207. value: '2',
  208. },
  209. ],
  210. categoryTree: [],
  211. labelCol: {
  212. xs: { span: 24 },
  213. sm: { span: 8 },
  214. },
  215. wrapperCol: {
  216. xs: { span: 24 },
  217. sm: { span: 16 },
  218. },
  219. editForm: {},
  220. editVisible: false,
  221. }
  222. },
  223. watch: {
  224. stockVisible(val) {
  225. this.loadCategoryTreeData()
  226. if (val) {
  227. if (this.taskId) {
  228. this.$nextTick(() => {
  229. this.getDetailList(this.taskId)
  230. })
  231. return
  232. }
  233. } else {
  234. this.dataSource = []
  235. this.ipagination.current = 1
  236. this.loading = false
  237. }
  238. },
  239. editVisible(val) {
  240. if (!val) {
  241. this.editForm = {}
  242. this.form.resetFields()
  243. }
  244. },
  245. },
  246. computed: {
  247. isShowBtn() {
  248. return this.openType !== 'detail' && this.form.taskStatus !== 1
  249. },
  250. },
  251. methods: {
  252. handleEdit(data) {
  253. this.editForm = { ...data }
  254. this.editVisible = true
  255. },
  256. onSubmitGoods() {
  257. postAction(this.url.edit, this.editForm).then((res) => {
  258. this.$message.success('操作成功')
  259. this.editVisible = false
  260. })
  261. },
  262. loadCategoryTreeData() {
  263. let params = {}
  264. params.id = ''
  265. queryMaterialCategoryTreeList(params).then((res) => {
  266. if (res) {
  267. this.categoryTree = []
  268. for (let i = 0; i < res.length; i++) {
  269. let temp = res[i]
  270. this.categoryTree.push(temp)
  271. }
  272. }
  273. })
  274. },
  275. handleCancel() {
  276. this.$emit('update:stockVisible', false)
  277. },
  278. //更新盘点数据
  279. handleUpdate() {
  280. let that = this
  281. const url = this.url.updateStock + this.taskId
  282. Modal.confirm({
  283. title: '是否确定更新盘点数据,确定后商品库存将按照当前的盘点数据进行更新',
  284. onOk() {
  285. getAction(url)
  286. .then((res) => {
  287. that.$message.success('操作成功')
  288. that.handleCancel()
  289. })
  290. .catch((err) => {
  291. this.$message.error('操作失败')
  292. })
  293. },
  294. onCancel() {
  295. console.log('Cancel')
  296. },
  297. })
  298. },
  299. handleOk() {
  300. getAction(this.url.taskCom + this.taskId)
  301. .then((res) => {
  302. this.$message.success('操作成功')
  303. })
  304. .catch((err) => {
  305. this.$message.error('操作失败')
  306. })
  307. this.handleCancel()
  308. },
  309. onChangeGoods() {
  310. this.$refs.selectModal.queryParam.depotId = this.form.depotId
  311. this.$refs.selectModal.showModal()
  312. },
  313. getDetailList(id) {
  314. const url = this.url.detail + id
  315. const form = this.$refs['editForm'].form
  316. getAction(url).then((res) => {
  317. const {
  318. depotId,
  319. taskName,
  320. taskStatus,
  321. taskType,
  322. createTime,
  323. createByName,
  324. materialCount,
  325. positionRange,
  326. creator,
  327. id,
  328. operBy,
  329. operTime,
  330. } = res.data
  331. form.setFieldsValue({
  332. depotId,
  333. taskName,
  334. taskStatus,
  335. taskType,
  336. createTime,
  337. createByName,
  338. materialCount,
  339. positionRange,
  340. creator,
  341. id,
  342. operBy,
  343. operTime,
  344. })
  345. this.getList(id)
  346. })
  347. },
  348. getList(id) {
  349. const url2 = '/stocktaking/detailByItemList'
  350. const params = { ...this.queryParams, taskStocktakingId: id }
  351. const url = url2 + '?pageNum=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
  352. postAction(url, params).then((res) => {
  353. this.dataSource = res.data
  354. this.ipagination.total = this.dataSource.length
  355. const materialExtendIdList = this.dataSource.map((item) => item.batchNumber)
  356. form.setFieldsValue({
  357. materialExtendIdList,
  358. })
  359. this.getForm(form.getFieldsValue())
  360. })
  361. },
  362. getGoods(rows, ids) {
  363. const str = ids
  364. .split(',')
  365. .filter((item) => item)
  366. .join(',')
  367. this.getBatchData(str)
  368. },
  369. findAllSelect() {
  370. const params = { ...this.$refs.selectModal.queryParam }
  371. getAction('/material/findBatchNumbersBySelect', params).then((res) => {
  372. this.$refs.selectModal.close()
  373. this.getBatchData(res.data)
  374. })
  375. },
  376. getBatchData(val) {
  377. const batchStr = val
  378. .split(',')
  379. .filter((item) => item)
  380. .join(',')
  381. const params = {
  382. batchNumber: batchStr,
  383. organId: '',
  384. mpList: '',
  385. prefixNo: '',
  386. }
  387. getMaterialByBatchNumber(params).then((res) => {
  388. this.dataSource.push(...res.data)
  389. this.dataSource = this.dataSource.reduce((acc, cur) => {
  390. const hasDuplicate = acc.some((item) => item.batchNumber === cur.batchNumber)
  391. if (!hasDuplicate) {
  392. acc.push(cur)
  393. }
  394. return acc
  395. }, [])
  396. })
  397. },
  398. getForm(val) {
  399. this.form = val
  400. this.$refs['editForm'].model = val
  401. },
  402. //删除
  403. handleDelete(record) {
  404. this.dataSource = this.dataSource.filter((item) => item.batchNumber !== record.batchNumber)
  405. },
  406. onClearList(val) {
  407. this.dataSource = []
  408. this.getForm(val)
  409. if (val.taskType === 1) {
  410. this.findAllSelect()
  411. }
  412. },
  413. },
  414. }
  415. </script>
  416. <style></style>