addInventoryDialog.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <el-dialog
  3. :visible.sync="dialogVisible"
  4. :title="dialogTile"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. :close-on-press-escape="false"
  8. v-loading="addDialogLoading"
  9. width="80%"
  10. >
  11. <HeaderTitle title="基本信息" size="16px"></HeaderTitle>
  12. <el-form
  13. :model="addForm"
  14. class="add_form"
  15. ref="addFormRef"
  16. :rules="rules"
  17. label-width="110px"
  18. >
  19. <el-row :gutter="20">
  20. <el-col :span="8">
  21. <el-form-item label="计划配置单号" prop="code">
  22. <el-input
  23. v-model="addForm.code"
  24. placeholder="自动生成"
  25. disabled
  26. ></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="8">
  30. <el-form-item label="计划配置名字" prop="name">
  31. <el-input
  32. :disabled="isBindPlan"
  33. v-model="addForm.name"
  34. placeholder="请输入"
  35. ></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="8">
  39. <el-form-item label="自动派单" prop="autoOrder">
  40. <el-select
  41. v-model="addForm.autoOrder"
  42. class="w100"
  43. placeholder="请选择"
  44. :disabled="isBindPlan"
  45. filterable
  46. >
  47. <el-option :value="1" label="是"></el-option>
  48. <el-option :value="0" label="否"></el-option>
  49. </el-select>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="8">
  53. <el-form-item label="规则名称" prop="ruleId">
  54. <el-select
  55. v-model="addForm.ruleId"
  56. class="w100"
  57. placeholder="请选择规则名称"
  58. @change="change_ruleId"
  59. :disabled="isBindPlan"
  60. filterable
  61. >
  62. <el-option
  63. v-for="item in ruleNameList"
  64. :key="item.id"
  65. :value="item.id"
  66. :label="item.name"
  67. @click.native="addForm.ruleName = item.name"
  68. ></el-option>
  69. </el-select>
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="8">
  73. <el-form-item label="计划盘点时长" prop="executorDuration">
  74. <el-input
  75. v-model.number="addForm.executorDuration"
  76. placeholder="请输入"
  77. :disabled="isBindPlan"
  78. >
  79. <template #suffix>分钟</template>
  80. </el-input>
  81. </el-form-item>
  82. </el-col>
  83. <el-col :span="8">
  84. <el-form-item label="盘点仓库" prop="warehouseId">
  85. <el-select
  86. placeholder="请选择"
  87. class="w100"
  88. :disabled="isBindPlan"
  89. v-model="addForm.warehouseId"
  90. @change="changeWarehouse"
  91. filterable
  92. >
  93. <el-option
  94. v-for="item in warehouseList"
  95. :key="item.id"
  96. :value="item.id"
  97. :label="item.name"
  98. @click.native="
  99. () => {
  100. addForm.bizTypeName = item.name;
  101. }
  102. "
  103. ></el-option>
  104. </el-select>
  105. </el-form-item>
  106. </el-col>
  107. <el-col :span="8">
  108. <el-form-item label="审核人" prop="approvalUserId">
  109. <el-select
  110. v-model="addForm.approvalUserId"
  111. size="small"
  112. style="width: 100%"
  113. :disabled="isBindPlan"
  114. filterable
  115. >
  116. <el-option
  117. v-for="item in uerList"
  118. :key="item.id"
  119. :value="item.id"
  120. :label="item.name"
  121. ></el-option>
  122. </el-select>
  123. </el-form-item>
  124. </el-col>
  125. <el-col :span="8">
  126. <el-form-item label="紧急程度" prop="urgent">
  127. <DictSelection
  128. :isProhibit="isBindPlan"
  129. dictName="紧急程度"
  130. clearable
  131. filterable
  132. v-model="addForm.urgent"
  133. >
  134. </DictSelection>
  135. </el-form-item>
  136. </el-col>
  137. <el-col :span="8" v-if="addForm.autoOrder">
  138. <el-form-item label="执行部门" prop="executeGroupId">
  139. <deptSelect
  140. :isBindPlan="isBindPlan"
  141. v-model="addForm.executeGroupId"
  142. @changeGroup="searchDeptNodeClick"
  143. />
  144. </el-form-item>
  145. </el-col>
  146. <el-col :span="8" v-if="addForm.autoOrder">
  147. <el-form-item label="执行人员" prop="executorId">
  148. <el-select
  149. v-model="addForm.executorId"
  150. @change="changeExecutor"
  151. :disabled="isBindPlan"
  152. size="small"
  153. style="width: 100%"
  154. filterable
  155. >
  156. <el-option
  157. v-for="item in executorList"
  158. :key="item.id"
  159. :value="item.id"
  160. :label="item.name"
  161. ></el-option>
  162. </el-select>
  163. </el-form-item>
  164. </el-col>
  165. <!-- <el-col :span="8">
  166. <el-form-item label="锁库盘点" prop="isTreasuryLock">
  167. <el-switch
  168. v-model="addForm.lockWarehouse"
  169. active-text="开"
  170. inactive-text="关"
  171. :active-value="1"
  172. :inactive-value="0"
  173. :disabled="isBindPlan"
  174. ></el-switch>
  175. </el-form-item>
  176. </el-col> -->
  177. <el-col :span="24">
  178. <el-form-item label="备注" prop="remark">
  179. <el-input
  180. placeholder="请输入"
  181. type="textarea"
  182. :rows="2"
  183. resize="none"
  184. v-model="addForm.remark"
  185. :disabled="isBindPlan"
  186. ></el-input>
  187. </el-form-item>
  188. </el-col>
  189. </el-row>
  190. <HeaderTitle title="盘点物品信息" size="16px">
  191. <el-select
  192. :disabled="isBindPlan"
  193. @change="dimensionChange"
  194. v-model="dimension"
  195. placeholder="请选择维度"
  196. >
  197. <el-option label="物品维度" :value="1"> </el-option>
  198. <el-option label="批次维度" :value="2"> </el-option>
  199. </el-select>
  200. <el-button
  201. v-if="!isBindPlan"
  202. style="margin-left: 10px"
  203. type="primary"
  204. @click="addProducts"
  205. >添加物品</el-button
  206. >
  207. </HeaderTitle>
  208. <el-table
  209. ref="table"
  210. :data="productList"
  211. :height="500"
  212. row-key="id"
  213. tooltip-effect="dark"
  214. border
  215. >
  216. <el-table-column label="序号" type="index" width="50">
  217. </el-table-column>
  218. <el-table-column
  219. label="物品编码"
  220. prop="categoryCode"
  221. :show-overflow-tooltip="true"
  222. ></el-table-column>
  223. <el-table-column
  224. label="物品名称"
  225. prop="categoryName"
  226. :show-overflow-tooltip="true"
  227. ></el-table-column>
  228. <el-table-column
  229. width="150"
  230. prop="categoryLevelPath"
  231. label="产品分类"
  232. :show-overflow-tooltip="true"
  233. ></el-table-column>
  234. <el-table-column
  235. label="批次号"
  236. prop="batchNo"
  237. :show-overflow-tooltip="true"
  238. ></el-table-column>
  239. <el-table-column
  240. label="牌号"
  241. prop="brandNum"
  242. :show-overflow-tooltip="true"
  243. ></el-table-column>
  244. <el-table-column
  245. label="型号"
  246. prop="categoryModel"
  247. :show-overflow-tooltip="true"
  248. ></el-table-column>
  249. <el-table-column
  250. label="规格"
  251. prop="specification"
  252. :show-overflow-tooltip="true"
  253. ></el-table-column>
  254. <el-table-column
  255. label="计量数量"
  256. prop="measureQuantity"
  257. :show-overflow-tooltip="true"
  258. ></el-table-column>
  259. <el-table-column
  260. label="计量单位"
  261. prop="measureUnit"
  262. :show-overflow-tooltip="true"
  263. ></el-table-column>
  264. <el-table-column
  265. label="重量"
  266. prop="weight"
  267. :show-overflow-tooltip="true"
  268. >
  269. </el-table-column>
  270. <el-table-column
  271. label="重量单位"
  272. prop="weightUnit"
  273. :show-overflow-tooltip="true"
  274. >
  275. </el-table-column>
  276. <el-table-column v-if="!isBindPlan" label="操作" width="100">
  277. <template slot-scope="{ row, $index }">
  278. <el-button @click="deleted(row, $index)" type="text" size="small"
  279. >删除</el-button
  280. >
  281. </template>
  282. </el-table-column>
  283. </el-table>
  284. </el-form>
  285. <div v-if="!isBindPlan" slot="footer">
  286. <el-button type="primary" size="small" @click="submit">提交</el-button>
  287. <el-button size="small" @click="handleClose">关闭</el-button>
  288. </div>
  289. <div v-else slot="footer">
  290. <el-button type="primary" size="small" @click="dialogVisible = false"
  291. >确定</el-button
  292. >
  293. <el-button size="small" @click="dialogVisible = false">关闭</el-button>
  294. </div>
  295. <selectType
  296. :visibleDialog.sync="visibleDialog"
  297. :treeIds="productType"
  298. :dimension="dimension"
  299. :warehouseId="addForm.warehouseId"
  300. :selectionIds="selectionIds"
  301. :loadTree.sync="loadTree"
  302. @selectTableData="addGoods"
  303. />
  304. </el-dialog>
  305. </template>
  306. <script>
  307. import { getTreeByGroup } from '@/api/classifyManage';
  308. import selectType from './selectType.vue';
  309. import { getCode } from '@/api/codeManagement';
  310. import {
  311. getInventoryPlanDetailById,
  312. saveInventoryPlan,
  313. updateInventoryPlan
  314. } from '@/api/inventory';
  315. import {
  316. getRule,
  317. getWarehouseList,
  318. getCategoryLevelIdByWarehouseId
  319. } from '@/api/ruleManagement/plan';
  320. import { getUserPage } from '@/api/system/organization';
  321. import deptSelect from '@/components/CommomSelect/new-dept-select.vue';
  322. export default {
  323. props: {
  324. dialogTile: {
  325. type: String,
  326. default: '新增临时盘点计划'
  327. },
  328. isBindPlan: {
  329. type: Boolean,
  330. default: function () {
  331. return false;
  332. }
  333. },
  334. id: {
  335. type: String,
  336. default: ''
  337. }
  338. },
  339. components: {
  340. deptSelect,
  341. selectType
  342. },
  343. data() {
  344. return {
  345. visibleDialog: false,
  346. type: 2, // 盘点类型 2仓储 4资产
  347. dimension: 1, // 盘点维度1物品 2批次
  348. factoryOptions: [],
  349. workshopOptions: [],
  350. productionLineOptions: [],
  351. stationOptions: [],
  352. codeList: [],
  353. addDialogLoading: false,
  354. dialogVisible: false,
  355. wh_checkStatus: [], // 盘点类型
  356. warehouseList: [], // 盘点仓库
  357. uerList: [], // 审核人
  358. executorList: [], // 执行人
  359. assetsType: null,
  360. planRuleInventoryDetailList: [],
  361. tableList: [],
  362. newColumns: [],
  363. selection: [],
  364. keyWord: '',
  365. total: 0,
  366. page: 1,
  367. size: 10,
  368. loadTree: true,
  369. productList: [],
  370. productType: [],
  371. addForm: {
  372. ruleId: '', // 规则名称
  373. ruleName: '', // 规则名称
  374. code: '', // 计划配置单号
  375. name: '', // 计划配置名称
  376. executeGroupId: '', // 执行部门code
  377. executeGroupName: '', // 执行部门name
  378. executorId: '', // 执行人id
  379. executorName: '', // 执行人name
  380. lockWarehouse: 1, // 是否锁库盘点
  381. urgent: '1', // 紧急程度
  382. warehouseId: '', // 盘点仓库Id
  383. autoOrder: 1, // 是否自动派单
  384. remark: '', // 备注
  385. approvalUserId: '', // 审核人Id
  386. approvalUserName: '', // 审核人name
  387. executorDuration: 0 // 盘点时长
  388. },
  389. rules: {
  390. code: [
  391. { required: true, message: '请输入计划配置单号', trigger: 'blur' }
  392. ],
  393. name: [
  394. { required: true, message: '请输入计划配置名称', trigger: 'blur' }
  395. ],
  396. autoOrder: [
  397. { required: true, message: '请选择是否自动派单', trigger: 'change' }
  398. ],
  399. ruleId: [
  400. { required: true, message: '请选择规则名称', trigger: 'change' }
  401. ],
  402. executorDuration: [
  403. { required: true, message: '请输入计划完成时长', trigger: 'blur' }
  404. ],
  405. warehouseId: [
  406. { required: true, message: '请选择盘点仓库', trigger: 'change' }
  407. ],
  408. executeGroupId: [
  409. { required: true, message: '请选择选择执行部门', trigger: 'change' }
  410. ],
  411. executorId: [
  412. { required: true, message: '请选择选择执行人员', trigger: 'change' }
  413. ]
  414. },
  415. ruleNameList: []
  416. };
  417. },
  418. watch: {
  419. dialogVisible(val) {
  420. if (val) {
  421. // 获取审核人列表数据
  422. this.getUserList();
  423. // 获取盘点仓库
  424. this._getWarehouse();
  425. // 获取计划单号
  426. this.getOrderCode();
  427. // 获取规则名称
  428. this._getRuleNameList();
  429. // 获取物品类型
  430. this.getGoodsList();
  431. if (
  432. this.dialogTile === '修改临时盘点计划' ||
  433. this.dialogTile === '临时盘点计划详情'
  434. ) {
  435. getInventoryPlanDetailById(this.id).then(async (res) => {
  436. res.urgent = String(res.urgent);
  437. this.addForm = res;
  438. this.dimension = res.planDetailVOS[0].batchNo ? 2 : 1;
  439. if (this.addForm.executeGroupId) {
  440. this.getUserList({ groupId: this.addForm.executeGroupId });
  441. }
  442. this.productList = res.planDetailVOS.map((item) => item.info);
  443. getCategoryLevelIdByWarehouseId({
  444. warehouseId: this.addForm.warehouseId
  445. }).then((data) => {
  446. console.log(data);
  447. this.productType = Array.from(new Set(data));
  448. });
  449. });
  450. } else {
  451. this.productList = [];
  452. this.addForm = {
  453. ruleId: '', // 规则名称
  454. ruleName: '', // 规则名称
  455. code: '', // 计划配置单号
  456. executeGroupId: '', // 执行部门code
  457. executeGroupName: '', // 执行部门name
  458. executorId: '', // 执行人id
  459. executorName: '', // 执行人name
  460. lockWarehouse: 1, // 是否锁库盘点
  461. urgent: '1', // 紧急程度
  462. warehouseId: '', // 盘点仓库Id
  463. autoOrder: 1, // 是否自动派单
  464. remark: '', // 备注
  465. approvalUserId: '', // 审核人Id
  466. approvalUserName: '', // 审核人name
  467. executorDuration: 0 // 盘点时长
  468. };
  469. }
  470. }
  471. }
  472. },
  473. computed: {
  474. clientEnvironmentId() {
  475. return this.$store.state.user.info.clientEnvironmentId;
  476. },
  477. selectionIds() {
  478. return this.productList.map((item) => item.categoryId);
  479. }
  480. },
  481. methods: {
  482. // 添加物品明细
  483. async addGoods(data) {
  484. console.log(data);
  485. let productList = data.map((item) => {
  486. return {
  487. ...item
  488. };
  489. });
  490. this.productList = this.productList.concat(productList);
  491. },
  492. addProducts() {
  493. if (this.addForm.warehouseId) {
  494. console.log(this.addForm.warehouseId);
  495. this.visibleDialog = true;
  496. } else {
  497. this.$message.warning('请选择盘点仓库');
  498. }
  499. },
  500. deleted(row, index) {
  501. this.productList.splice(index, 1);
  502. },
  503. selecctedRow(val) {
  504. this.selection = val;
  505. },
  506. dimensionChange() {
  507. this.productList = [];
  508. },
  509. checkSelectable(row) {
  510. return true;
  511. },
  512. // 改变规则名称
  513. change_ruleId(val) {
  514. this.addForm.ruleName = this.ruleNameList.filter(
  515. (item) => item.id === val
  516. )[0].name;
  517. },
  518. // 获取物品类型列表
  519. async getGoodsList() {
  520. const { data } = await getTreeByGroup({ type: this.type });
  521. console.log('data------', data);
  522. this.codeList = data;
  523. },
  524. // 获取规则名列表
  525. async _getRuleNameList() {
  526. const res = await getRule({ status: 1, type: 4, pageNum: 1, size: -1 });
  527. if (res.list) {
  528. this.ruleNameList = res.list || [];
  529. }
  530. },
  531. // 获取计划配置单号
  532. async getOrderCode(tips) {
  533. const code = await getCode('inventoryconfig_code');
  534. this.$set(this.addForm, 'code', code);
  535. },
  536. // 执行人选择
  537. changeExecutor(val) {
  538. if (val) {
  539. this.addForm.executorId = val;
  540. this.addForm.executorName = this.executorList.filter(
  541. (item) => item.id === val
  542. )[0].name;
  543. }
  544. },
  545. // 仓库选择
  546. changeWarehouse(val) {
  547. if (val) {
  548. this.addForm.warehouseId = val;
  549. this.addForm.warehouseName = this.warehouseList.filter(
  550. (item) => item.id === val
  551. )[0].name;
  552. this.productList = [];
  553. getCategoryLevelIdByWarehouseId({ warehouseId: val }).then((data) => {
  554. console.log(data);
  555. this.productType = Array.from(new Set(data));
  556. });
  557. }
  558. },
  559. // 关闭弹窗
  560. handleClose() {
  561. this.dialogVisible = false;
  562. this.$refs.addFormRef.resetFields();
  563. this.addForm.assetsName = '';
  564. this.assetsType = null;
  565. this.addForm = {
  566. ruleId: '', // 规则名称
  567. ruleName: '', // 规则名称
  568. code: '', // 计划配置单号
  569. executeGroupId: '', // 执行部门code
  570. executeGroupName: '', // 执行部门name
  571. executorId: '', // 执行人id
  572. executorName: '', // 执行人name
  573. lockWarehouse: 1, // 是否锁库盘点
  574. urgent: '1', // 紧急程度
  575. warehouseId: '', // 盘点仓库Id
  576. autoOrder: 1, // 是否自动派单
  577. remark: '', // 备注
  578. approvalUserId: '', // 审核人Id
  579. approvalUserName: '', // 审核人name
  580. executorDuration: 0 // 盘点时长
  581. };
  582. },
  583. // 封装 - 获取盘点仓库
  584. async _getWarehouse() {
  585. const res = await getWarehouseList({});
  586. this.warehouseList = res.map((item) => {
  587. return { ...item, name: item.factoryName + '-' + item.name };
  588. });
  589. },
  590. //选择部门(搜索)
  591. searchDeptNodeClick(info, row) {
  592. console.log(info);
  593. console.log(row);
  594. if (info) {
  595. const params = { groupId: info };
  596. this.getUserList(params);
  597. this.addForm.executeGroupName = row.name;
  598. } else {
  599. this.addForm.executeGroupId = null;
  600. }
  601. },
  602. // 获取审核人列表、巡点检人员
  603. async getUserList(params) {
  604. try {
  605. let data = { pageNum: 1, size: -1 };
  606. // 如果传了参数就是获取巡点检人员数据
  607. if (params) {
  608. data = Object.assign(data, params);
  609. }
  610. const res = await getUserPage(data);
  611. if (params) {
  612. this.executorList = res.list;
  613. } else {
  614. this.uerList = res.list;
  615. }
  616. } catch (error) {}
  617. },
  618. submit() {
  619. console.log(this.addForm);
  620. this.$refs.addFormRef.validate(async (valid) => {
  621. let res = null;
  622. if (valid) {
  623. let params = {
  624. ...this.addForm,
  625. planDetailAddPOList: this.productList.map((item) => {
  626. return {
  627. batchNo: item.batchNo,
  628. categoryId: item.categoryId,
  629. categoryName: item.categoryName,
  630. info: item
  631. };
  632. })
  633. };
  634. if (this.productList?.length > 0) {
  635. if (this.dialogTile === '修改临时盘点计划') {
  636. res = await updateInventoryPlan(params);
  637. } else {
  638. res = await saveInventoryPlan(params);
  639. }
  640. } else {
  641. return this.$message.error('请选择需要盘点物品');
  642. }
  643. if (res.code == 0) {
  644. this.handleClose();
  645. console.log(res.message);
  646. this.$message.success({
  647. message:res.message,
  648. duration:2000
  649. });
  650. this.$emit('refreshList');
  651. }
  652. }
  653. });
  654. },
  655. handleChangeassetDict(data) {
  656. console.log(data);
  657. }
  658. }
  659. };
  660. </script>
  661. <style lang="scss" scoped>
  662. ::v-deep .el-row {
  663. display: flex;
  664. flex-wrap: wrap;
  665. }
  666. .add_form {
  667. ::v-deep .el-form-item {
  668. margin-bottom: 20px !important;
  669. }
  670. }
  671. .table_search {
  672. margin-bottom: 5px;
  673. }
  674. </style>