checkModal.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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="getList">查询</a-button>
  60. <a-button style="margin-left: 8px" @click="getList">重置</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="handleCancel">完成盘点</a-button>
  99. <a-button v-if="isShowBtn" @click="handleOk" 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 { JeecgListMixin } from '@/mixins/JeecgListMixin'
  141. // import { Form } from 'ant-design-vue'
  142. // const useForm = Form.useForm
  143. export default {
  144. components: { editForm, JSelectMaterialModal },
  145. mixins: [newTableMixin],
  146. props: {
  147. rules: {
  148. type: Object,
  149. default: () => {
  150. return {}
  151. },
  152. },
  153. stockVisible: {
  154. type: Boolean,
  155. default: false,
  156. },
  157. title: {
  158. type: String,
  159. default: '新增',
  160. },
  161. spinnerList: {
  162. type: Array,
  163. default: () => [],
  164. },
  165. deoptData: {
  166. type: Array,
  167. default: () => [],
  168. },
  169. taskId: {
  170. type: String,
  171. default: '',
  172. },
  173. openType: {
  174. type: String,
  175. default: 'add',
  176. },
  177. },
  178. data() {
  179. return {
  180. width: '1600px',
  181. visible: false,
  182. confirmLoading: false,
  183. prefixNo: '',
  184. loading: false,
  185. dataSource: [],
  186. columns: table.checkGoodsColumns,
  187. url: {
  188. add: '/stocktaking/add',
  189. update: '/stocktaking/detailUpdate',
  190. edit: '/stocktaking/itemUpdate',
  191. },
  192. form: {},
  193. isShow: false,
  194. stockType: 'check',
  195. queryParams: { categoryId: '', materialName: '', batchNumber: '', position: '', isDifference: null },
  196. isDifferenceData: [
  197. {
  198. label: '是',
  199. value: '1',
  200. },
  201. {
  202. label: '否',
  203. value: '2',
  204. },
  205. ],
  206. categoryTree: [],
  207. labelCol: {
  208. xs: { span: 24 },
  209. sm: { span: 8 },
  210. },
  211. wrapperCol: {
  212. xs: { span: 24 },
  213. sm: { span: 16 },
  214. },
  215. editForm: {},
  216. editVisible: false,
  217. }
  218. },
  219. watch: {
  220. stockVisible(val) {
  221. this.loadCategoryTreeData()
  222. if (val) {
  223. if (this.taskId) {
  224. this.$nextTick(() => {
  225. this.getDetailList(this.taskId)
  226. })
  227. return
  228. }
  229. } else {
  230. this.dataSource = []
  231. this.ipagination.current = 1
  232. this.loading = false
  233. }
  234. },
  235. editVisible(val) {
  236. if (!val) {
  237. this.editForm = {}
  238. this.form.resetFields()
  239. }
  240. },
  241. },
  242. computed: {
  243. isShowBtn() {
  244. return this.openType !== 'detail' || this.form.taskStatus !== 1
  245. },
  246. },
  247. methods: {
  248. handleEdit(data) {
  249. this.editForm = { ...data }
  250. this.editVisible = true
  251. },
  252. onSubmitGoods() {
  253. postAction(this.url.edit, this.editForm).then((res) => {
  254. this.$message.success('操作成功')
  255. this.editVisible = false
  256. })
  257. },
  258. loadCategoryTreeData() {
  259. let params = {}
  260. params.id = ''
  261. queryMaterialCategoryTreeList(params).then((res) => {
  262. if (res) {
  263. this.categoryTree = []
  264. for (let i = 0; i < res.length; i++) {
  265. let temp = res[i]
  266. this.categoryTree.push(temp)
  267. }
  268. }
  269. })
  270. },
  271. handleCancel() {
  272. this.$emit('update:stockVisible', false)
  273. },
  274. handleOk() {
  275. this.$refs.editForm.form.validateFields((err, values) => {
  276. if (!err) {
  277. const params = { ...values }
  278. if (params.taskType === 2) {
  279. params.materialExtendIdList = this.dataSource.map((item) => item.batchNumber)
  280. }
  281. const url = this.openType === 'add' ? this.url.add : this.url.update
  282. postAction(url, params).then((res) => {
  283. this.$message.success('操作成功')
  284. this.handleCancel()
  285. })
  286. }
  287. })
  288. },
  289. onChangeGoods() {
  290. this.$refs.selectModal.queryParam.depotId = this.form.depotId
  291. this.$refs.selectModal.showModal()
  292. },
  293. getDetailList(id) {
  294. const url = '/stocktaking/detail/' + id
  295. const form = this.$refs['editForm'].form
  296. getAction(url).then((res) => {
  297. const {
  298. depotId,
  299. taskName,
  300. taskStatus,
  301. taskType,
  302. createTime,
  303. createByName,
  304. materialCount,
  305. positionRange,
  306. creator,
  307. id,
  308. operBy,
  309. operTime,
  310. } = res.data
  311. form.setFieldsValue({
  312. depotId,
  313. taskName,
  314. taskStatus,
  315. taskType,
  316. createTime,
  317. createByName,
  318. materialCount,
  319. positionRange,
  320. creator,
  321. id,
  322. operBy,
  323. operTime,
  324. })
  325. this.getList(id)
  326. })
  327. },
  328. getList(id) {
  329. const url2 = '/stocktaking/detailByItemList'
  330. const params = { ...this.queryParams, taskStocktakingId: id }
  331. const url = url2 + '?pageNum=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize
  332. postAction(url, params).then((res) => {
  333. this.dataSource = res.data
  334. this.ipagination.total = this.dataSource.length
  335. const materialExtendIdList = this.dataSource.map((item) => item.batchNumber)
  336. form.setFieldsValue({
  337. materialExtendIdList,
  338. })
  339. this.getForm(form.getFieldsValue())
  340. })
  341. },
  342. getGoods(rows, ids) {
  343. const str = ids
  344. .split(',')
  345. .filter((item) => item)
  346. .join(',')
  347. this.getBatchData(str)
  348. },
  349. findAllSelect() {
  350. const params = { ...this.$refs.selectModal.queryParam }
  351. getAction('/material/findBatchNumbersBySelect', params).then((res) => {
  352. this.$refs.selectModal.close()
  353. this.getBatchData(res.data)
  354. })
  355. },
  356. getBatchData(val) {
  357. const batchStr = val
  358. .split(',')
  359. .filter((item) => item)
  360. .join(',')
  361. const params = {
  362. batchNumber: batchStr,
  363. organId: '',
  364. mpList: '',
  365. prefixNo: '',
  366. }
  367. getMaterialByBatchNumber(params).then((res) => {
  368. this.dataSource.push(...res.data)
  369. this.dataSource = this.dataSource.reduce((acc, cur) => {
  370. const hasDuplicate = acc.some((item) => item.batchNumber === cur.batchNumber)
  371. if (!hasDuplicate) {
  372. acc.push(cur)
  373. }
  374. return acc
  375. }, [])
  376. })
  377. },
  378. getForm(val) {
  379. this.form = val
  380. this.$refs['editForm'].model = val
  381. },
  382. //删除
  383. handleDelete(record) {
  384. this.dataSource = this.dataSource.filter((item) => item.batchNumber !== record.batchNumber)
  385. },
  386. onClearList(val) {
  387. this.dataSource = []
  388. this.getForm(val)
  389. if (val.taskType === 1) {
  390. this.findAllSelect()
  391. }
  392. },
  393. },
  394. }
  395. </script>
  396. <style></style>