checkModal.vue 13 KB

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