addInventoryDialog copy.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  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. <el-form
  12. :model="addForm"
  13. class="add_form"
  14. ref="addFormRef"
  15. :rules="rules"
  16. label-width="110px"
  17. >
  18. <el-row :gutter="20">
  19. <el-col :span="8">
  20. <el-form-item label="计划配置单号" prop="code">
  21. <el-input
  22. v-model="addForm.planCode"
  23. placeholder="自动生成"
  24. disabled
  25. ></el-input>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="8">
  29. <el-form-item label="计划配置名称" prop="planName">
  30. <el-input
  31. v-model="addForm.planName"
  32. placeholder="请输入"
  33. :disabled="isBindPlan"
  34. ></el-input>
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="8">
  38. <el-form-item label="自动派单" prop="autoOrder">
  39. <el-select
  40. v-model="addForm.autoOrder"
  41. class="w100"
  42. placeholder="请选择"
  43. :disabled="isBindPlan"
  44. filterable
  45. >
  46. <el-option :value="1" label="是"></el-option>
  47. <el-option :value="0" label="否"></el-option>
  48. </el-select>
  49. </el-form-item>
  50. </el-col>
  51. <el-col :span="8">
  52. <el-form-item label="规则名称" prop="ruleId">
  53. <el-select
  54. v-model="addForm.ruleId"
  55. class="w100"
  56. placeholder="请选择规则名称"
  57. @change="change_ruleId"
  58. :disabled="isBindPlan"
  59. filterable
  60. >
  61. <el-option
  62. v-for="item in ruleNameList"
  63. :key="item.id"
  64. :value="item.id"
  65. :label="item.name"
  66. @click.native="addForm.ruleName = item.name"
  67. ></el-option>
  68. </el-select>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="8">
  72. <el-form-item label="计划盘点时长" prop="duration">
  73. <el-input
  74. v-model.number="addForm.duration"
  75. placeholder="请输入"
  76. :disabled="isBindPlan"
  77. >
  78. <template #suffix>分钟</template>
  79. </el-input>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="8">
  83. <el-form-item label="盘点类型" prop="inventoryType">
  84. <el-select
  85. v-model="addForm.inventoryType"
  86. class="w100"
  87. placeholder="请选择"
  88. @change="chooseType"
  89. disabled
  90. filterable
  91. >
  92. <el-option
  93. v-for="item in inventoryTypeStatus"
  94. :key="item.code"
  95. :value="item.code"
  96. :label="item.label"
  97. ></el-option>
  98. </el-select>
  99. </el-form-item>
  100. </el-col>
  101. <el-col v-if="addForm.inventoryType == 1" :span="8">
  102. <el-form-item label="盘点仓库" prop="warehouseId">
  103. <el-select
  104. placeholder="请选择"
  105. class="w100"
  106. :disabled="isBindPlan"
  107. v-model="addForm.warehouseId"
  108. @change="changeWarehouse"
  109. filterable
  110. >
  111. <el-option
  112. v-for="item in warehouseList"
  113. :key="item.id"
  114. :value="item.id"
  115. :label="item.name"
  116. @click.native="
  117. () => {
  118. addForm.bizTypeName = item.name;
  119. }
  120. "
  121. ></el-option>
  122. </el-select>
  123. </el-form-item>
  124. </el-col>
  125. <!-- <el-col :span="8">
  126. <el-form-item label="审核人" prop="verifyUserId">
  127. <el-select
  128. v-model="addForm.verifyUserId"
  129. size="small"
  130. style="width: 100%"
  131. :disabled="isBindPlan"
  132. filterable
  133. >
  134. <el-option
  135. v-for="item in uerList"
  136. :key="item.id"
  137. :value="item.id"
  138. :label="item.name"
  139. ></el-option>
  140. </el-select>
  141. </el-form-item>
  142. </el-col> -->
  143. <el-col :span="8">
  144. <el-form-item
  145. :label="type == 2 ? '产品分类' : '资产分类'"
  146. prop="categoryLevelId"
  147. >
  148. <ele-tree-select
  149. multiple
  150. clearable
  151. :disabled="isBindPlan"
  152. :data="codeList"
  153. @change="codeListValue"
  154. v-model="addForm.categoryLevelId"
  155. valueKey="id"
  156. labelKey="name"
  157. :show-checkbox="true"
  158. :check-strictly="true"
  159. filterable
  160. placeholder="请选择"
  161. />
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="8">
  165. <el-form-item label="紧急程度" prop="urgent">
  166. <DictSelection
  167. :isProhibit="isBindPlan"
  168. dictName="紧急程度"
  169. clearable
  170. filterable
  171. v-model="addForm.urgent"
  172. >
  173. </DictSelection>
  174. </el-form-item>
  175. </el-col>
  176. <el-col :span="8" v-if="addForm.autoOrder">
  177. <el-form-item label="执行部门" prop="executeGroupId">
  178. <deptSelect
  179. :isBindPlan="isBindPlan"
  180. v-model="addForm.executeGroupId"
  181. @changeGroup="searchDeptNodeClick"
  182. />
  183. </el-form-item>
  184. </el-col>
  185. <el-col :span="8" v-if="addForm.autoOrder">
  186. <el-form-item label="执行人员" prop="executorId">
  187. <el-select
  188. v-model="addForm.executorId"
  189. @change="changeExecutor"
  190. :disabled="isBindPlan"
  191. size="small"
  192. style="width: 100%"
  193. filterable
  194. >
  195. <el-option
  196. v-for="item in executorList"
  197. :key="item.id"
  198. :value="item.id"
  199. :label="item.name"
  200. ></el-option>
  201. </el-select>
  202. </el-form-item>
  203. </el-col>
  204. <el-col v-if="addForm.inventoryType == 1" :span="8">
  205. <el-form-item label="锁库盘点" prop="isTreasuryLock">
  206. <el-switch
  207. v-model="addForm.lockWarehouse"
  208. active-text="开"
  209. inactive-text="关"
  210. :active-value="1"
  211. :inactive-value="0"
  212. :disabled="isBindPlan"
  213. ></el-switch>
  214. </el-form-item>
  215. </el-col>
  216. <el-col :span="8">
  217. <el-form-item label="状态" prop="enable">
  218. <el-switch
  219. v-model="addForm.enable"
  220. :disabled="isBindPlan"
  221. active-text="开"
  222. inactive-text="关"
  223. :active-value="1"
  224. :inactive-value="0"
  225. ></el-switch>
  226. </el-form-item>
  227. </el-col>
  228. <el-col :span="24">
  229. <el-form-item label="备注" prop="remark">
  230. <el-input
  231. placeholder="请输入"
  232. type="textarea"
  233. :rows="2"
  234. resize="none"
  235. v-model="addForm.remark"
  236. :disabled="isBindPlan"
  237. ></el-input>
  238. </el-form-item>
  239. </el-col>
  240. </el-row>
  241. <div class="table_search">
  242. <el-select
  243. style="margin-right: 10px"
  244. :disabled="isBindPlan"
  245. @change="dimensionChange"
  246. v-model="dimension"
  247. placeholder="请选择维度"
  248. >
  249. <el-option label="物品维度" :value="1"> </el-option>
  250. <el-option label="批次维度" :value="2"> </el-option>
  251. </el-select>
  252. <el-input
  253. v-if="!isBindPlan"
  254. style="width: 400px"
  255. placeholder="请输入名称/编码/批次号/型号/规格"
  256. v-model="keyWord"
  257. class="input-with-select"
  258. >
  259. <el-button
  260. slot="append"
  261. icon="el-icon-search"
  262. type="primary"
  263. @click="getProductList"
  264. >搜索</el-button
  265. >
  266. </el-input>
  267. </div>
  268. <el-table
  269. ref="table"
  270. :data="productList"
  271. row-key="id"
  272. @selection-change="selecctedRow"
  273. tooltip-effect="dark"
  274. border
  275. >
  276. <el-table-column
  277. v-if="!isBindPlan"
  278. align="center"
  279. width="50"
  280. :reserve-selection="true"
  281. :selectable="checkSelectable"
  282. type="selection"
  283. ></el-table-column>
  284. <el-table-column label="序号" type="index" width="50">
  285. </el-table-column>
  286. <el-table-column
  287. label="物品编码"
  288. prop="categoryCode"
  289. :show-overflow-tooltip="true"
  290. ></el-table-column>
  291. <el-table-column
  292. label="物品名称"
  293. prop="categoryName"
  294. :show-overflow-tooltip="true"
  295. ></el-table-column>
  296. <el-table-column
  297. label="批次号"
  298. prop="batchNo"
  299. :show-overflow-tooltip="true"
  300. ></el-table-column>
  301. <el-table-column
  302. label="牌号"
  303. prop="brandNum"
  304. :show-overflow-tooltip="true"
  305. ></el-table-column>
  306. <el-table-column
  307. label="型号"
  308. prop="categoryModel"
  309. :show-overflow-tooltip="true"
  310. ></el-table-column>
  311. <el-table-column
  312. label="规格"
  313. prop="specification"
  314. :show-overflow-tooltip="true"
  315. ></el-table-column>
  316. <el-table-column
  317. label="计量数量"
  318. prop="measureQuantity"
  319. :show-overflow-tooltip="true"
  320. ></el-table-column>
  321. <el-table-column
  322. label="计量单位"
  323. prop="measureUnit"
  324. :show-overflow-tooltip="true"
  325. ></el-table-column>
  326. <el-table-column
  327. label="重量"
  328. prop="weight"
  329. :show-overflow-tooltip="true"
  330. >
  331. </el-table-column>
  332. <el-table-column
  333. label="重量单位"
  334. prop="weightUnit"
  335. :show-overflow-tooltip="true"
  336. >
  337. </el-table-column>
  338. </el-table>
  339. <el-pagination
  340. v-if="!isBindPlan"
  341. background
  342. layout="total, sizes, prev, pager, next, jumper"
  343. :total="total"
  344. :page-sizes="[10, 20, 50, 100]"
  345. :page-size.sync="size"
  346. :current-page.sync="page"
  347. @current-change="getProductList"
  348. @size-change="getProductList"
  349. >
  350. </el-pagination>
  351. <!-- 库外 -->
  352. <!-- <Assets
  353. ref="assetsRef"
  354. :assetsName="addForm.assetsName"
  355. :assetsType="assetsType"
  356. :planRuleInventoryDetailList="planRuleInventoryDetailList"
  357. :isBindPlan = "isBindPlan"
  358. v-if="
  359. addForm.bizType === 2 &&
  360. addForm.assetsName != '物料' &&
  361. addForm.assetsName != '产品' &&
  362. addForm.assetsName != '备品备件'
  363. "
  364. /> -->
  365. <!-- 库内 库存台账 -->
  366. <AssetsInWarehouse
  367. ref="assetsRef"
  368. :assetsName="addForm.assetsName"
  369. :warehouseId="addForm.bizTypeId"
  370. :assetsType="assetsType"
  371. :bizType="addForm.inventoryType"
  372. :planRuleInventoryDetailList="planRuleInventoryDetailList"
  373. :isBindPlan="isBindPlan"
  374. />
  375. </el-form>
  376. <div v-if="!isBindPlan" slot="footer">
  377. <el-button type="primary" size="small" @click="submit">提交</el-button>
  378. <el-button size="small" @click="handleClose">关闭</el-button>
  379. </div>
  380. <div v-else slot="footer">
  381. <el-button type="primary" size="small" @click="dialogVisible = false"
  382. >确定</el-button
  383. >
  384. <el-button size="small" @click="dialogVisible = false">关闭</el-button>
  385. </div>
  386. </el-dialog>
  387. </template>
  388. <script>
  389. import { getFactoryarea } from '@/api/factoryModel';
  390. import { listWorkshopByParentId, listFactoryLine } from '@/api/factoryModel';
  391. import { listByProductionLineId } from '@/api/workforceManagement/team';
  392. import selectTree from '@/components/selectTree/index_other.vue';
  393. import { getTreeByGroup } from '@/api/classifyManage';
  394. import { inventoryTypeStatus } from '@/utils/dict/rulesManagement';
  395. import { mapGetters } from 'vuex';
  396. // import { wh_checkStatus} from '@/utils/dict/warehouse'
  397. import { getCode } from '@/api/ruleManagement/matter';
  398. import AssetsInWarehouse from './AssetsInWarehouse';
  399. import { fieldModel } from '@/api/codeManagement';
  400. import {
  401. getRule,
  402. getProductList,
  403. getBatchList,
  404. getWarehouseList,
  405. saveStocktakingPlan,
  406. updateStocktakingPlan,
  407. getInventoryDetailById
  408. } from '@/api/ruleManagement/plan';
  409. import { getUserPage } from '@/api/system/organization';
  410. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  411. export default {
  412. props: {
  413. dialogTile: {
  414. type: String,
  415. default: '新增盘点计划配置'
  416. },
  417. isBindPlan: {
  418. type: Boolean,
  419. default: function () {
  420. return false;
  421. }
  422. },
  423. id: {
  424. type: String,
  425. default: ''
  426. }
  427. },
  428. components: {
  429. deptSelect,
  430. AssetsInWarehouse,
  431. selectTree
  432. },
  433. data() {
  434. return {
  435. type: 2, // 盘点类型 2仓储 4资产
  436. dimension: 1, // 盘点维度1物品 2批次
  437. factoryOptions: [],
  438. workshopOptions: [],
  439. productionLineOptions: [],
  440. stationOptions: [],
  441. codeList: [],
  442. inventoryTypeStatus,
  443. addDialogLoading: false,
  444. dialogVisible: false,
  445. wh_checkStatus: [], // 盘点类型
  446. warehouseList: [], // 盘点仓库
  447. uerList: [], // 审核人
  448. executorList: [], // 执行人
  449. assetsType: null,
  450. planRuleInventoryDetailList: [],
  451. tableList: [],
  452. newColumns: [],
  453. selection: [],
  454. keyWord: '',
  455. total: 0,
  456. page: 1,
  457. size: 10,
  458. productList: [],
  459. addForm: {
  460. code: '', // 计划配置单号
  461. planName: '', // 计划配置名称
  462. categoryId: 0, // 类别ID
  463. autoOrder: 1, // 是否自动派单
  464. ruleId: '', // 规则名称
  465. categoryLevelId: [], // 物品Ids
  466. inventoryType: 1, // 盘点类型
  467. bizTypeId: '', // 盘点仓库Id
  468. bizTypeName: '', // 盘点仓库name
  469. verifyUserId: '', // 审核人Id
  470. verifyUserName: '', // 审核人name
  471. duration: null, // 盘点时长
  472. assetDict: '', // 资产分类id
  473. assetsName: '', // 资产分类name
  474. urgent: '1', // 紧急程度
  475. executeGroupId: '', // 执行部门code
  476. executeGroupName: '', // 执行部门name
  477. executorId: '', // 执行人id
  478. executorName: '', // 执行人name
  479. isTreasuryLock: false, // 是否锁库盘点
  480. enable: 1, // 状态
  481. remark: '', // 备注
  482. productionLineId: '',
  483. productionLineName: '',
  484. workshopId: '',
  485. workshopName: '',
  486. plantId: '',
  487. plantName: '',
  488. stationId: '',
  489. stationName: ''
  490. },
  491. rules: {
  492. planName: [
  493. { required: true, message: '请输入计划配置名称', trigger: 'blur' }
  494. ],
  495. autoOrder: [
  496. { required: true, message: '请选择是否自动派单', trigger: 'change' }
  497. ],
  498. ruleId: [
  499. { required: true, message: '请选择规则名称', trigger: 'change' }
  500. ],
  501. duration: [
  502. { required: true, message: '请输入计划完成时长', trigger: 'blur' }
  503. ],
  504. inventoryType: [
  505. { required: true, message: '请选择盘点类型', trigger: 'change' }
  506. ],
  507. // plantId: [
  508. // {
  509. // required: true,
  510. // message: '请选择厂房',
  511. // trigger: 'change'
  512. // }
  513. // ],
  514. warehouseId: [
  515. { required: true, message: '请选择盘点仓库', trigger: 'change' }
  516. ],
  517. verifyUserId: [
  518. { required: false, message: '请选择审核人', trigger: 'change' }
  519. ],
  520. executeGroupId: [
  521. { required: true, message: '请选择选择执行部门', trigger: 'change' }
  522. ],
  523. executorId: [
  524. { required: true, message: '请选择选择执行人员', trigger: 'change' }
  525. ],
  526. assetDict: [
  527. { required: true, message: '请选择资产分类', trigger: 'change' }
  528. ]
  529. },
  530. ruleNameList: []
  531. };
  532. },
  533. watch: {
  534. dialogVisible(val) {
  535. if (val) {
  536. // // 获取审核人列表数据
  537. // this.getUserList();
  538. // 获取盘点仓库
  539. this._getWarehouse();
  540. // 获取计划单号
  541. this.getOrderCode();
  542. // 获取规则名称
  543. this._getRuleNameList();
  544. // 获取物品类型
  545. this.getGoodsList();
  546. // 获取工厂列表
  547. this.getFactoryareaList();
  548. if (
  549. this.dialogTile === '修改盘点计划配置' ||
  550. this.dialogTile === '盘点计划配置详情'
  551. ) {
  552. getInventoryDetailById(this.id).then(async (res) => {
  553. console.log(res);
  554. res.warehouseId = res.warehouseId > 0 ? res.warehouseId : '';
  555. res.urgent = String(res.urgent);
  556. res.categoryLevelId = res.categoryLevelId
  557. ? res.categoryLevelId.split(',')
  558. : [];
  559. this.addForm = res;
  560. this.dimension = res.planConfigDetailVOList[0].batch_no ? 2 : 1;
  561. if (this.addForm.executeGroupId) {
  562. this.getUserList({ groupId: this.addForm.executeGroupId });
  563. }
  564. if (this.dialogTile === '修改盘点计划配置') {
  565. // 回显物品列表
  566. let categoryIds = this.addForm.planConfigDetailVOList.map(
  567. (item) => item.categoryId
  568. );
  569. await this.getProductList();
  570. let list = this.productList.filter((item) =>
  571. categoryIds.includes(item.categoryId)
  572. );
  573. list.forEach((item) => {
  574. this.$refs.table.toggleRowSelection(item);
  575. });
  576. } else {
  577. this.productList = res.planConfigDetailVOList;
  578. }
  579. });
  580. } else {
  581. this.productList = [];
  582. this.selection = [];
  583. this.addForm = {
  584. code: '', // 计划配置单号
  585. planName: '', // 计划配置名称
  586. categoryId: 0, // 类别ID
  587. autoOrder: 1, // 是否自动派单
  588. ruleId: '', // 规则名称
  589. categoryLevelId: [], // 物品Ids
  590. inventoryType: 1, // 盘点类型
  591. bizTypeId: '', // 盘点仓库Id
  592. bizTypeName: '', // 盘点仓库name
  593. verifyUserId: '', // 审核人Id
  594. verifyUserName: '', // 审核人name
  595. duration: null, // 盘点时长
  596. assetDict: '', // 资产分类id
  597. assetsName: '', // 资产分类name
  598. urgent: '1', // 紧急程度
  599. executeGroupId: '', // 执行部门code
  600. executeGroupName: '', // 执行部门name
  601. executorId: '', // 执行人id
  602. executorName: '', // 执行人name
  603. isTreasuryLock: false, // 是否锁库盘点
  604. enable: 1, // 状态
  605. remark: '', // 备注
  606. productionLineId: '',
  607. productionLineName: '',
  608. workshopId: '',
  609. workshopName: '',
  610. plantId: '',
  611. plantName: '',
  612. stationId: '',
  613. stationName: ''
  614. };
  615. }
  616. }
  617. },
  618. planRulesDetails(val) {
  619. if (!this.dialogVisible) return;
  620. this.addForm = val;
  621. this.addForm.assetsName = val.assetDictDESC;
  622. this.assetsType = val.assetDict;
  623. // this.warehousingType.map(item => {
  624. // if (val.assetsName == item.label) {
  625. // this.assetsType = item.code
  626. // }
  627. // })
  628. // this.assetsType = this.warehousingType.filter(
  629. // item => item.code === val.assetDict.code
  630. // )[0].type
  631. // this.addForm.assetDict = this.warehousingType.filter(
  632. // item => item.code === val.assetDict.code
  633. // )[0].key
  634. // 根据部门回显人员
  635. const params = { deptCode: val.executeGroupId, status: 1 };
  636. this.getUserList(params);
  637. this.planRuleInventoryDetailList = val.planRuleInventoryDetailList;
  638. console.log(
  639. 'planRuleInventoryDetailList',
  640. this.planRuleInventoryDetailList
  641. );
  642. // 将 planRuleInventoryDetailList 保存到store,在 assets.vue 中获取用来高亮树节点和请求右边的列表
  643. // 取出 planRuleInventoryDetailList 里面的分类 bizTypeId、bizTypeName,用来高亮树节点和请求右边的列表
  644. // console.log('资产分类:', val.assetDict)
  645. // console.log(this.addForm.assetsName)
  646. }
  647. },
  648. computed: {
  649. clientEnvironmentId() {
  650. return this.$store.state.user.info.clientEnvironmentId;
  651. }
  652. },
  653. methods: {
  654. selecctedRow(val) {
  655. this.selection = val;
  656. },
  657. dimensionChange() {
  658. this.selection = [];
  659. this.$refs.table.clearSelection();
  660. if (this.addForm.warehouseId) {
  661. this.getProductList();
  662. }
  663. },
  664. checkSelectable(row) {
  665. return true;
  666. },
  667. async getProductList() {
  668. let data = null;
  669. if (this.dimension == 1) {
  670. data = await getProductList({
  671. keyWord: this.keyWord,
  672. warehouseId: this.type == 2 ? this.addForm?.warehouseId : '',
  673. categoryLevelIds: this.addForm?.categoryLevelId.join(','),
  674. pageNum: this.page,
  675. size: this.size
  676. });
  677. } else {
  678. data = await getBatchList({
  679. keyWord: this.keyWord,
  680. warehouseId: this.type == 2 ? this.addForm?.warehouseId : '',
  681. categoryLevelIds: this.addForm?.categoryLevelId.join(','),
  682. pageNum: this.page,
  683. size: this.size
  684. });
  685. }
  686. this.total = data.count;
  687. this.productList = data.list;
  688. },
  689. // 改变规则名称
  690. change_ruleId(val) {
  691. this.addForm.ruleName = this.ruleNameList.filter(
  692. (item) => item.id === val
  693. )[0].name;
  694. },
  695. // 获取工厂数据
  696. getFactoryareaList() {
  697. getFactoryarea({
  698. type: 1,
  699. size: 9999,
  700. type: 2
  701. }).then((res) => {
  702. this.factoryOptions = res.list;
  703. });
  704. },
  705. change_factoryId(id) {
  706. this.addForm.workshopId = '';
  707. this.addForm.productionLineId = '';
  708. this.addForm.stationId = '';
  709. this.workshopOptions = [];
  710. this.productionLineOptions = [];
  711. this.stationOptions = [];
  712. this.addForm.plantId = id;
  713. this.addForm.plantName = this.factoryOptions.filter(
  714. (item) => item.id === id
  715. )[0].pathName;
  716. this.getListWorkshopByParentId(id);
  717. },
  718. // 获取车间
  719. getListWorkshopByParentId(id) {
  720. listWorkshopByParentId(id).then((res) => {
  721. this.workshopOptions = res;
  722. });
  723. },
  724. change_workshop(id) {
  725. this.addForm.productionLineId = '';
  726. this.addForm.stationId = '';
  727. this.productionLineOptions = [];
  728. this.stationOptions = [];
  729. this.addForm.workshopName = this.workshopOptions.filter(
  730. (item) => item.id === id
  731. )[0].name;
  732. this.getlistFactoryLineByParentId(id);
  733. },
  734. // 获取产线
  735. getlistFactoryLineByParentId(id) {
  736. listFactoryLine([id]).then((res) => {
  737. this.productionLineOptions = res;
  738. });
  739. },
  740. change_productionLineId(id) {
  741. this.addForm.stationId = '';
  742. this.stationOptions = [];
  743. this.addForm.productionLineName = this.productionLineOptions.filter(
  744. (item) => item.id === id
  745. )[0].name;
  746. this.getlistByProductionLineId(id);
  747. },
  748. // 获取工位
  749. getlistByProductionLineId(id) {
  750. listByProductionLineId(id).then((res) => {
  751. this.stationOptions = res;
  752. });
  753. },
  754. change_stationId(id) {
  755. this.$forceUpdate();
  756. this.addForm.stationName = this.stationOptions.filter(
  757. (item) => item.id === id
  758. )[0].name;
  759. },
  760. // 物品类型选择
  761. async codeListValue(val) {
  762. if (this.addForm.warehouseId) {
  763. console.log('val---------', val);
  764. this.addForm.categoryLevelId = val;
  765. this.getProductList();
  766. }
  767. },
  768. // 获取物品类型列表
  769. async getGoodsList() {
  770. const { data } = await getTreeByGroup({ type: this.type });
  771. console.log('data------', data);
  772. this.codeList = data;
  773. },
  774. // 获取规则名列表
  775. async _getRuleNameList() {
  776. const res = await getRule({ status: 1, type: 4, pageNum: 1, size: -1 });
  777. if (res.list) {
  778. this.ruleNameList = res.list || [];
  779. }
  780. },
  781. // 获取计划配置单号
  782. async getOrderCode(tips) {
  783. const code = await getCode('inventoryconfig_code');
  784. this.$set(this.addForm, 'planCode', code);
  785. },
  786. // 执行人选择
  787. changeExecutor(val) {
  788. if (val) {
  789. this.addForm.executorId = val;
  790. this.addForm.executorName = this.executorList.filter(
  791. (item) => item.id === val
  792. )[0].name;
  793. }
  794. },
  795. // 仓库选择
  796. changeWarehouse(val) {
  797. if (val) {
  798. this.addForm.warehouseId = val;
  799. this.addForm.warehouseName = this.warehouseList.filter(
  800. (item) => item.id === val
  801. )[0].name;
  802. }
  803. this.getProductList();
  804. },
  805. // 关闭弹窗
  806. handleClose() {
  807. this.dialogVisible = false;
  808. this.$refs.addFormRef.resetFields();
  809. if (this.$refs.searchTree) {
  810. this.$refs.searchTree.clearHandle();
  811. }
  812. if (this.addForm.inventoryType == 2) {
  813. this.$refs.assetsRef._clearTreeTableData();
  814. }
  815. this.addForm.assetsName = '';
  816. this.assetsType = null;
  817. this.addForm = {
  818. code: '', // 计划配置单号
  819. planName: '', // 计划配置名称
  820. categoryId: 0,
  821. autoOrder: 1, // 是否自动派单
  822. ruleId: '', // 规则名称
  823. inventoryType: '', // 盘点类型
  824. bizTypeId: '', // 盘点仓库Id
  825. bizTypeName: '', // 盘点仓库name
  826. verifyUserId: '', // 审核人Id
  827. verifyUserName: '', // 审核人name
  828. duration: null, // 盘点时长
  829. assetDict: '', // 资产分类id
  830. assetsName: '', // 资产分类name
  831. urgent: '1', // 紧急程度
  832. executeGroupId: '', // 执行部门code
  833. executeGroupName: '', // 执行部门name
  834. executorId: '', // 执行人id
  835. executorName: '', // 执行人name
  836. isTreasuryLock: false, // 是否锁库盘点
  837. enable: 1, // 状态
  838. remark: '' // 备注
  839. };
  840. },
  841. // 封装 - 获取盘点仓库
  842. async _getWarehouse() {
  843. const res = await getWarehouseList({});
  844. console.log(res);
  845. this.warehouseList = res.map((item) => {
  846. return { ...item, name: item.factoryName + '-' + item.name };
  847. });
  848. },
  849. //选择部门(搜索)
  850. searchDeptNodeClick(info, row) {
  851. if (info) {
  852. const params = { groupId: info };
  853. this.getUserList(params);
  854. this.addForm.executeGroupName = row.name;
  855. } else {
  856. this.addForm.executeGroupId = null;
  857. }
  858. },
  859. // 获取审核人列表、巡点检人员
  860. async getUserList(params) {
  861. try {
  862. let data = { pageNum: 1, size: -1 };
  863. // 如果传了参数就是获取巡点检人员数据
  864. if (params) {
  865. data = Object.assign(data, params);
  866. }
  867. const res = await getUserPage(data);
  868. if (params) {
  869. this.executorList = res.list;
  870. } else {
  871. this.uerList = res.list;
  872. }
  873. } catch (error) {}
  874. },
  875. // 资产分类
  876. handleAssetsChange(item) {
  877. this.addForm.assetsName = item.dictValue;
  878. this.assetsType = item.dictCode;
  879. this.$nextTick(
  880. () =>
  881. this.$refs.assetsRef && this.$refs.assetsRef.handleAssetsChange()
  882. );
  883. },
  884. // 参数处理
  885. getParams() {
  886. const { classificationList, tableSelectionList } =
  887. this.$refs.assetsRef.getSelectList();
  888. console.log('getParams-tableSelectionList', tableSelectionList);
  889. return {
  890. ...this.addForm,
  891. classificationList: classificationList.map((i) => ({
  892. classificationID: i.id,
  893. classificationName: i.name
  894. })),
  895. planRuleInventoryDetailList:
  896. this.formData && this.formData.inventoryType === 2
  897. ? tableSelectionList.map((item) => ({
  898. assetBrand: item.brand,
  899. assetCode: item.code,
  900. assetId: item.id,
  901. assetLocationId: `${this.initLocation(
  902. item.positionWorkshop
  903. )}${this.initLocation(item.positionLine)}${this.initLocation(
  904. item.positionFarm
  905. )}${this.initLocation(item.positionFactory)}`,
  906. assetLocationName: `${this.initLocation(
  907. item.positionWorkshopCode
  908. )}${this.initLocation(
  909. item.positionLineCode
  910. )}${this.initLocation(
  911. item.positionFarmCode
  912. )}${this.initLocation(item.positionFactoryCode)}`,
  913. assetName: item.name,
  914. assetSku: item.specifications,
  915. assetTypeDict: this.addForm ? this.addForm.assetDict : '',
  916. bizTypeId: item.bizTypeId,
  917. bizTypeName: item.bizTypeName,
  918. unit: this.addForm ? this.addForm.unit : ''
  919. }))
  920. : tableSelectionList,
  921. planRuleType: 'INVENTORY'
  922. };
  923. },
  924. initLocation(inp) {
  925. return inp ? inp + ',' : '';
  926. },
  927. // x选择盘点类型
  928. chooseType(val) {
  929. if (val == 2) {
  930. // 库外盘点
  931. this.addForm.warehouseId = '';
  932. this.addForm.warehouseName = '';
  933. this.addForm.lockWarehouse = 0;
  934. this.type = 4;
  935. } else {
  936. // 库内盘点
  937. this.addForm.plantId = '';
  938. this.addForm.workshopId = '';
  939. this.addForm.productionLineId = '';
  940. this.addForm.stationId = '';
  941. this.workshopOptions = [];
  942. this.productionLineOptions = [];
  943. this.stationOptions = [];
  944. this.type = 2;
  945. }
  946. this.addForm.categoryLevelId = [];
  947. this.getGoodsList();
  948. },
  949. // 提交
  950. // submit() {
  951. // console.log(this.addForm);
  952. // this.$refs.addFormRef.validate(async (valid) => {
  953. // if (valid) {
  954. // // const params = this.getParams();
  955. // // console.log(
  956. // // 'planRuleInventoryDetailList',
  957. // // params.planRuleInventoryDetailList
  958. // // );
  959. // // if (this.addOrUpdate != 'edit') {
  960. // // if (
  961. // // !(
  962. // // params.classificationList.length ||
  963. // // params.planRuleInventoryDetailList.length
  964. // // )
  965. // // ) {
  966. // // return this.$message.error('请选择资产分类台账!');
  967. // // }
  968. // // }
  969. // if (this.addForm.inventoryType == 2) {
  970. // this.addForm.locationId = [
  971. // this.addForm.plantId,
  972. // this.addForm.workshopId,
  973. // this.addForm.productionLineId,
  974. // this.addForm.stationId
  975. // ].join(',');
  976. // this.addForm.locationName = [
  977. // this.addForm.plantName,
  978. // this.addForm.workshopName,
  979. // this.addForm.productionLineName,
  980. // this.addForm.stationName
  981. // ].join(',');
  982. // }
  983. // if (!this.addForm.warehouseId) {
  984. // this.addForm.warehouseId = 0;
  985. // }
  986. // if (this.addForm.inventoryType == 2 && !this.addForm.plantId) {
  987. // this.$message.error('请至少选择所属厂房!');
  988. // return false;
  989. // }
  990. // let res = '';
  991. // let message = '';
  992. // if (this.dialogTile === '修改盘点计划配置') {
  993. // res = await updateStocktakingPlan(this.addForm);
  994. // message = '修改成功!';
  995. // } else {
  996. // res = await saveStocktakingPlan(this.addForm);
  997. // message = '新增成功!';
  998. // }
  999. // if (res.code == 0) {
  1000. // this.handleClose();
  1001. // this.$message.success(message);
  1002. // this.$emit('refreshList');
  1003. // }
  1004. // }
  1005. // });
  1006. // },
  1007. submit() {
  1008. console.log(this.addForm);
  1009. this.$refs.addFormRef.validate(async (valid) => {
  1010. let res = null;
  1011. if (valid) {
  1012. if (this.dialogTile === '修改盘点计划配置') {
  1013. } else {
  1014. if (this.selection?.length > 0) {
  1015. res = await saveStocktakingPlan({
  1016. ...this.addForm,
  1017. categoryLevelId: this.addForm.categoryLevelId.join(','),
  1018. details: this.selection.map((item) => {
  1019. return {
  1020. batchNo: item.batchNo,
  1021. categoryId: item.categoryId,
  1022. categoryName: item.categoryName
  1023. };
  1024. })
  1025. });
  1026. } else {
  1027. return this.$message.error('请选择需要盘点物品');
  1028. }
  1029. console.log(this.addForm);
  1030. }
  1031. if (res.code == 0) {
  1032. this.handleClose();
  1033. this.$message.success(res.message);
  1034. this.$emit('refreshList');
  1035. }
  1036. }
  1037. });
  1038. },
  1039. handleChangeassetDict(data) {
  1040. console.log(data);
  1041. }
  1042. }
  1043. };
  1044. </script>
  1045. <style lang="scss" scoped>
  1046. ::v-deep .el-row {
  1047. display: flex;
  1048. flex-wrap: wrap;
  1049. }
  1050. .add_form {
  1051. ::v-deep .el-form-item {
  1052. margin-bottom: 20px !important;
  1053. }
  1054. }
  1055. .table_search {
  1056. margin-bottom: 5px;
  1057. }
  1058. </style>