sparepart.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. <template>
  2. <view>
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="申请备品备件"
  8. @clickLeft="back"
  9. ></uni-nav-bar>
  10. <view class="sparepart-container">
  11. <view class="infos">
  12. <!-- <view class="col">
  13. <text class="label">申领单号</text>
  14. <text class="content">{{ formData.applyOrder }}</text>
  15. </view>
  16. <view class="col">
  17. <text class="label">期望完成时间</text>
  18. <text class="content" @click="timeShow = true">{{
  19. formData.expectedPerformanceTime | timeFilter
  20. }}</text>
  21. </view> -->
  22. <u-form
  23. labelPosition="left"
  24. :model="formData"
  25. ref="formRef"
  26. labelWidth="250"
  27. labelAlign="left"
  28. class="baseForm"
  29. >
  30. <!-- <u-form-item label="审核人部门" prop="verifyDeptName" borderBottom>
  31. <u-input
  32. :value="formData.verifyDeptName"
  33. disableColor="#ffffff"
  34. placeholder="请选择"
  35. disabled
  36. type="select"
  37. clearable
  38. @click.native="$refs.verifyTreePicker._show()"
  39. />
  40. <view slot="right" style="display: flex; align-item: center">
  41. <u-icon
  42. v-show="formData.verifyDeptName"
  43. name="close-circle-fill"
  44. @click="verifyDeptConfirm([], '')"
  45. ></u-icon>
  46. <u-icon name="arrow-right"></u-icon>
  47. </view>
  48. </u-form-item>
  49. <u-form-item label="审核人" prop="approvalUserId" borderBottom>
  50. <picker
  51. @change="
  52. e =>
  53. handlePicker(
  54. e,
  55. userList,
  56. 'approvalUserId',
  57. 'approvalUserName'
  58. )
  59. "
  60. :value="pickerIndex"
  61. :range="userList"
  62. range-key="name"
  63. >
  64. <u-input
  65. :value="formData.approvalUserName"
  66. disableColor="#ffffff"
  67. placeholder="请选择"
  68. disabled
  69. type="select"
  70. />
  71. </picker>
  72. <view slot="right" style="display: flex; align-item: center">
  73. <u-icon
  74. v-show="formData.approvalUserName"
  75. name="close-circle-fill"
  76. @click="
  77. handlePicker(null, [], 'approvalUserId', 'approvalUserName')
  78. "
  79. ></u-icon>
  80. <u-icon name="arrow-right"></u-icon>
  81. </view>
  82. </u-form-item> -->
  83. <u-form-item
  84. label="仓库:"
  85. prop="warehouseId"
  86. style="height: 120rpx"
  87. required
  88. >
  89. <!-- <uni-datetime-picker type="datetime" v-model="formData.datetime" @change="changeLog" /> -->
  90. <picker
  91. @change="bindPickerChange"
  92. :value="warehosueVal"
  93. :range="warehouseList"
  94. range-key="name"
  95. >
  96. <input
  97. disabled
  98. class="uni-input"
  99. v-model="warehosueName"
  100. placeholder="请选择"
  101. />
  102. </picker>
  103. </u-form-item>
  104. <!-- <u-form-item
  105. label="期望完成时间:"
  106. prop="approvalUserId"
  107. style="height: 120rpx"
  108. >
  109. <text class="content" @click="timeShow = true">{{
  110. formData.expectedPerformanceTime | timeFilter
  111. }}</text>
  112. </u-form-item> -->
  113. </u-form>
  114. </view>
  115. <view class="detail-title">
  116. 申请明细
  117. <u-button @click="addGoods" type="success" size="small">
  118. 添加物品
  119. </u-button></view
  120. >
  121. <view class="detail-content">
  122. <uni-collapse
  123. :key="forceUpdate"
  124. ref="collapseRef"
  125. v-model="collapseVal"
  126. accordion
  127. >
  128. <uni-collapse-item
  129. :typeOpen="1"
  130. :name="item.informationCode"
  131. :show-animation="true"
  132. v-for="(item, index) in registerlist"
  133. :key="item.informationCode"
  134. >
  135. <template slot="title">
  136. <view class="row">
  137. <view class="col">
  138. <view class="col-item">
  139. {{ item.informationName }}({{ item.informationCode }})
  140. </view>
  141. </view>
  142. <view class="col">
  143. <view class="col-item">
  144. 规格/型号:{{ item.specification }}/{{ item.modelType }}
  145. </view>
  146. <view class="col-item">
  147. {{ item.isUnpack ? "包装单位" : "计量单位" }}:{{
  148. item.isUnpack
  149. ? `${item.measuringUnit}/${item.minPackUnit}`
  150. : item.measuringUnit
  151. }}
  152. </view>
  153. </view>
  154. <view class="col">
  155. <view class="col-item">
  156. 所需数量:{{ item.selectNum || 0 }}{{ item.measuringUnit }}
  157. </view>
  158. <view
  159. class="col-item text-primary"
  160. @click.stop="openPlus(item)"
  161. >
  162. 添加备品备件
  163. </view>
  164. </view>
  165. </view>
  166. </template>
  167. <view class="instance-list">
  168. <view class="" v-for="(itm, index) in item.tableData">
  169. <view class="row">
  170. <uni-icons
  171. type="trash"
  172. size="27"
  173. color="red"
  174. @click="handleDelete(item, itm, index)"
  175. ></uni-icons>
  176. <view class="col">
  177. <view class="col-item">
  178. {{ itm.onlyCode }}
  179. </view>
  180. </view>
  181. <view class="col">
  182. <view class="col-item"> 批次号:{{ itm.batchNum }} </view>
  183. <view class="col-item"> 包装编码:{{ itm.num }} </view>
  184. </view>
  185. <view class="col">
  186. <view class="col-item">
  187. {{ itm.manufactureTime ? "生产日期" : "采购日期" }}:{{
  188. itm.manufactureTime || itm.procurementTime
  189. }}
  190. </view>
  191. </view>
  192. <view class="col" v-if="!itm.isUnpack">
  193. <view class="col-item">
  194. 最小包装单元:{{ itm.measurementUnit }}{{ itm.unit }}/{{
  195. itm.minPackUnit
  196. }}
  197. </view>
  198. </view>
  199. <view class="col">
  200. <view class="col-item">
  201. 货位:{{ itm.warehouseName }}-{{ itm.areaName }}-{{
  202. itm.shelfCode
  203. }}-{{ itm.cargoSpaceCode }}
  204. </view>
  205. </view>
  206. </view>
  207. </view>
  208. </view>
  209. </uni-collapse-item>
  210. </uni-collapse>
  211. <!-- <view class="col" v-for="(item, index) in registerlist" :key="item.id">
  212. <view>
  213. <view>{{ item.informationName }}</view>
  214. <view style="color: #aaaaaa"
  215. >({{ item.informationCode }}/{{ item.modelType }})</view
  216. >
  217. </view>
  218. <u-number-box
  219. v-model="item.num"
  220. :step="1"
  221. :min="0"
  222. :name="index"
  223. :disabledInput="true"
  224. @change="numChange"
  225. ></u-number-box>
  226. </view>
  227. <view class="plus" @click="openPlus">+</view> -->
  228. </view>
  229. </view>
  230. <view class="sparepart-footer">
  231. <button class="primary" @click="toSubmit">提交</button>
  232. <button class="defualt" @click="back">返回</button>
  233. </view>
  234. <u-datetime-picker
  235. @confirm="timeConfirm"
  236. @cancel="timeCancel"
  237. :show="timeShow"
  238. v-model="formData.expectedPerformanceTime"
  239. mode="datetime"
  240. ></u-datetime-picker>
  241. <u-popup :show="popShow" @close="close" @open="open">
  242. <view class="select-container" v-if="popShow">
  243. <view class="title"
  244. >添加备件
  245. <view class="btn-box">
  246. <text class="btn cancel" @click="close">取消</text>
  247. <text class="btn confirm" @click="popConfirm">确定</text>
  248. </view>
  249. </view>
  250. <!-- <input
  251. type="text"
  252. :value="curClassification.name"
  253. placeholder="选择分类"
  254. @click="openPicker"
  255. /> -->
  256. <input
  257. type="text"
  258. @input="nameFilter"
  259. v-model="searchKey"
  260. placeholder="搜索编号"
  261. />
  262. <view class="self-table-header">
  263. <view class="table-code">备品备件编码</view>
  264. <view class="table-batch">批次号</view>
  265. </view>
  266. <view class="table-wrapper">
  267. <view class="listContent">
  268. <checkbox-group @change="selectionChange">
  269. <view
  270. class="listBox"
  271. v-for="(item, index) in tableData"
  272. :key="index"
  273. >
  274. <label>
  275. <view class="self-table-tr">
  276. <view class="table-code">{{ item.onlyCode }}</view>
  277. <view class="table-batch">{{ item.batchNum }}</view>
  278. <view class="table-date"></view>
  279. <view class="other-info">
  280. <view>包装编码:{{ item.num }}</view>
  281. <view v-if="!currentRow.isUnpack"
  282. >最小包装单元:{{ item.measurementUnit
  283. }}{{ item.unit }}/{{ item.minPackUnit }}</view
  284. >
  285. <view v-if="item.manufactureTime || item.procurementTime"
  286. >{{
  287. item.procurementTime ? "采购日期" : "生产日期"
  288. }}:{{
  289. item.manufactureTime || item.procurementTime
  290. }}</view
  291. >
  292. <view style="width: 100%"
  293. >货位:{{ item.warehouseName }}-{{ item.areaName }}-{{
  294. item.shelfCode
  295. }}-{{ item.cargoSpaceCode }}</view
  296. >
  297. </view>
  298. <view class="checked">
  299. <checkbox
  300. :value="item.onlyCode"
  301. :checked="selectList.includes(item.onlyCode)"
  302. ></checkbox>
  303. </view>
  304. </view>
  305. </label>
  306. </view>
  307. </checkbox-group>
  308. <u-empty style="margin-top: 20vh" v-if="!tableData.length" />
  309. </view>
  310. </view>
  311. </view>
  312. </u-popup>
  313. <!-- <ba-tree-picker
  314. ref="treePicker"
  315. :multiple="false"
  316. @select-change="confirm"
  317. title="选择分类"
  318. :localdata="listData"
  319. valueKey="id"
  320. textKey="name"
  321. childrenKey="children"
  322. /> -->
  323. <ba-tree-picker
  324. ref="verifyTreePicker"
  325. key="verify"
  326. :multiple="false"
  327. @select-change="verifyDeptConfirm"
  328. title="选择部门"
  329. :localdata="deptList"
  330. valueKey="code"
  331. textKey="name"
  332. childrenKey="children"
  333. />
  334. <u-modal
  335. :show="showConfirm"
  336. title="提示"
  337. @confirm="warehosueConfirm"
  338. @cancel="warehosueCancel"
  339. :showCancelButton="true"
  340. content="仓库修改后,已添加的备品备件信息将会被清空,是否要继续修改仓库?"
  341. ></u-modal>
  342. </view>
  343. </template>
  344. <script>
  345. import { get, postJ, post } from "@/utils/api.js";
  346. import dayjs from "dayjs";
  347. import { debounce } from "lodash";
  348. let [page, size, isEnd] = [1, 10, true];
  349. export default {
  350. components: {},
  351. filters: {
  352. timeFilter(inp) {
  353. return inp && dayjs(inp).format("YYYY-MM-DD HH:mm");
  354. },
  355. },
  356. data() {
  357. return {
  358. workOrderId: "",
  359. planFinishTime: "",
  360. workOrderCode: "",
  361. showConfirm: false,
  362. popShow: false,
  363. timeShow: false,
  364. time: "",
  365. pageId: "",
  366. pickerDeptShow: false,
  367. list: [],
  368. treeList: [],
  369. classificationId: "",
  370. // formData: {
  371. // applyOrder: getRuleNo('BJ'),
  372. // expectedPerformanceTime: new Date().getTime()
  373. // },
  374. registerlist: [],
  375. listData: [],
  376. curClassification: {
  377. id: "",
  378. name: "",
  379. },
  380. planCode: "",
  381. formData: {
  382. approvalUserId: "",
  383. approvalUserName: "",
  384. verifyDeptCode: "",
  385. verifyDeptName: "",
  386. // expectedPerformanceTime: new Date().getTime()
  387. },
  388. pickerIndex: 0,
  389. userList: [],
  390. deptList: [], //部门
  391. searchKey: "",
  392. tableData: [],
  393. selectIndex: [],
  394. chooseItem: {},
  395. sourceCode: null,
  396. sourceId: null,
  397. // 关键词搜索
  398. nameFilter: debounce(this.getTableData, 500),
  399. chooseIndex: null,
  400. warehouseId: "",
  401. warehosueName: "",
  402. warehouseList: [],
  403. warehosueVal: 0,
  404. memo: [],
  405. selectList: [],
  406. currentRow: {},
  407. forceUpdate: false,
  408. collapseVal: "",
  409. };
  410. },
  411. onLoad(options) {
  412. this.planCode = options.planCode;
  413. this.sourceCode = options.sourceCode;
  414. this.sourceId = options.sourceId;
  415. // this.getDept()
  416. // this._getPlanInfo()
  417. this.getwarehouseList();
  418. // this.workOrderId = workOrderId
  419. // this.workOrderCode = workOrderCode
  420. // this.planFinishTime = planFinishTime
  421. // this._getClassification()
  422. },
  423. computed: {
  424. selectAll: {
  425. set(val) {
  426. if (val) {
  427. this.selectList = this.tableData.map((i) => i.onlyCode);
  428. } else {
  429. this.selectList = [];
  430. }
  431. },
  432. get() {
  433. return (
  434. this.selectList.length &&
  435. this.selectList.length == this.tableData.length
  436. );
  437. },
  438. },
  439. },
  440. onShow() {
  441. uni.$off("setSelectList");
  442. uni.$on("setSelectList", (selectList) => {
  443. if (selectList?.length) {
  444. this.registerlist = this.registerlist.filter((item) => {
  445. const index = selectList.findIndex((i) => i.curId === item.curId);
  446. if (index > -1) {
  447. selectList.splice(index, 1);
  448. }
  449. return index > -1;
  450. });
  451. this.registerlist.push(
  452. ...selectList.map((item) => {
  453. return {
  454. curId: item.curId,
  455. isUnpack: item.isUnpack,
  456. informationCode: item.assetCode || item.informationCode,
  457. informationName: item.assetName || item.informationName,
  458. specification: item.specification,
  459. minPackUnit: item.minPackUnit,
  460. modelType: item.modelType,
  461. measuringUnit: item.unit || item.measuringUnit,
  462. tableData: item.tableData || [],
  463. num: 0,
  464. selectNum: 0,
  465. };
  466. })
  467. );
  468. }
  469. });
  470. },
  471. onReachBottom: function () {
  472. if (isEnd) {
  473. return;
  474. }
  475. // 显示加载图标
  476. uni.showLoading({
  477. title: "数据加载中",
  478. });
  479. this.getMoreLists();
  480. },
  481. methods: {
  482. showPopu() {
  483. this.popShow = true;
  484. },
  485. changeLog(e) {
  486. console.log("change事件:", e);
  487. },
  488. // 选择审核人确定
  489. handlePicker(e, list, idKey, nameKey) {
  490. if (idKey) {
  491. this.formData[idKey] = list[e?.detail.value]?.id;
  492. }
  493. if (nameKey) {
  494. this.formData[nameKey] = list[e?.detail.value]?.name;
  495. }
  496. this.$nextTick(() => {
  497. if (idKey === "assetType" || idKey === "bizScene") {
  498. this.$refs.formRef.validateField(idKey);
  499. }
  500. });
  501. },
  502. // 部门确认
  503. verifyDeptConfirm(data, name) {
  504. this.formData.verifyDeptCode = data[0];
  505. this.formData.verifyDeptName = name;
  506. this.formData.approvalUserId = "";
  507. this.formData.approvalUserName = "";
  508. this.getUser(data[0]);
  509. },
  510. // 获取部门
  511. getDept() {
  512. get(this.apiUrl + "/main/org/dept/effectiveTree").then((res) => {
  513. if (res?.success) {
  514. this.deptList = res.data;
  515. }
  516. });
  517. },
  518. // 获取人员
  519. getUser(deptCode) {
  520. post(this.apiUrl + "/main/user/list", {
  521. deptCode,
  522. page: 1,
  523. size: 9999,
  524. }).then((res) => {
  525. if (res?.success) {
  526. this.userList = res.data.items.map((item) => {
  527. item.name = item.trueName;
  528. item.id = item.userId;
  529. return item;
  530. });
  531. }
  532. });
  533. },
  534. numChange(val) {
  535. if (val?.value === 0) {
  536. this.registerlist.splice(val.name, 1);
  537. }
  538. },
  539. back() {
  540. uni.navigateBack({
  541. delta: 1,
  542. });
  543. },
  544. selectionChange({ detail }) {
  545. this.selectList = detail.value;
  546. },
  547. // 点击提交
  548. toSubmit() {
  549. // if (!this.formData.expectedPerformanceTime) {
  550. // uni.showToast({
  551. // icon: 'error',
  552. // title: '请选择期望完成时间'
  553. // })
  554. // return
  555. // }
  556. // if (!this.formData.approvalUserName) {
  557. // uni.showToast({
  558. // icon: 'error',
  559. // title: '请选择审核人'
  560. // })
  561. // return
  562. // }
  563. const stockOutApplyDetailList = this.registerlist.filter(
  564. (i) => i.tableData.length
  565. );
  566. if (!stockOutApplyDetailList.length) {
  567. uni.showToast({
  568. icon: "error",
  569. title: "请添加申请备件",
  570. });
  571. return;
  572. }
  573. const params = {
  574. ...this.formData,
  575. sparePartsApplyDetailList: this.registerlist
  576. .filter((i) => i.tableData.length)
  577. .map((i) => i.tableData)
  578. .flat()
  579. .map((i) => {
  580. delete i.id;
  581. return {
  582. informationCode: i.assetCode,
  583. informationName: i.assetName,
  584. assetCode: i.onlyCode,
  585. };
  586. }),
  587. sourceCode: this.sourceCode,
  588. sourceId: this.sourceId,
  589. sourceType: 2,
  590. };
  591. params.expectedPerformanceTime = dayjs(
  592. params.expectedPerformanceTime
  593. ).format("YYYY-MM-DD HH:mm:ss");
  594. postJ(this.apiUrl + "/sparePartsApply/save", params).then((res) => {
  595. if (res?.success) {
  596. this.back();
  597. }
  598. });
  599. },
  600. addGoods() {
  601. if (!this.warehouseId) {
  602. uni.showToast({
  603. title: "请选择仓库!",
  604. icon: "none",
  605. });
  606. return;
  607. }
  608. const storageKey = Date.now() + "";
  609. uni.setStorageSync(storageKey, this.registerlist);
  610. uni.navigateTo({
  611. url:
  612. "/pages/warehouse/outHouse/selectOutType?warehousingType=7&warehousingName=备品备件" +
  613. "&storageKey=" +
  614. storageKey +
  615. "&warehouseId=" +
  616. this.warehouseId,
  617. });
  618. },
  619. handleDelete(item, row, index) {
  620. uni.showModal({
  621. title: `确定删除${row.onlyCode}?`,
  622. content: "",
  623. confirmText: "确认",
  624. success: function (res) {
  625. if (res.confirm) {
  626. item.tableData.splice(index, 1);
  627. item.selectNum = item.tableData.reduce((next, pre) => {
  628. next += pre.isUnpack ? 1 : pre.measurementUnit || 0;
  629. return next;
  630. }, 0);
  631. }
  632. },
  633. });
  634. },
  635. // 选择备品备件
  636. openPicker() {
  637. this.$refs.treePicker._show();
  638. },
  639. handleSelectionChange(val) {
  640. console.log("handleSelectionChangeval", val);
  641. this.selectIndex = val.detail.index;
  642. },
  643. //获取备品备件分类
  644. _getClassification() {
  645. postJ(this.apiUrl + "/classificationTree/list", [4]).then((res) => {
  646. if (res?.success) {
  647. this.listData = res.data;
  648. }
  649. });
  650. },
  651. // 查询计划备件明细
  652. _getPlanInfo() {
  653. postJ(this.apiUrl + "/sparePartsApply/getSparePartsApplyDetail", {
  654. planCode: this.planCode,
  655. }).then((res) => {
  656. if (res?.success) {
  657. this.registerlist = res.data.map((item) => {
  658. item.tableData = [];
  659. item.curId = item.informationCode;
  660. delete item.equipmentCode;
  661. return item;
  662. });
  663. }
  664. });
  665. },
  666. close() {
  667. this.selectIndex = [];
  668. // this.$refs.tableRef.clearSelection()
  669. this.popShow = false;
  670. this.chooseItem = {};
  671. this.currentRow = {};
  672. },
  673. // 确定选择的备品备件
  674. popConfirm() {
  675. const selectList = [
  676. ...this.memo,
  677. ...this.tableData.filter((item) =>
  678. this.selectList.includes(item.onlyCode)
  679. ),
  680. ];
  681. if (!selectList.length) {
  682. uni.showToast({
  683. icon: "none",
  684. title: "请选择需添加的备品备件",
  685. });
  686. return;
  687. }
  688. // this.registerlist.push(this.chooseItem)
  689. this.currentRow.tableData = selectList;
  690. let selectNum = 0;
  691. this.currentRow.tableData.forEach((item) => {
  692. selectNum += item.isUnpack ? 1 : item.measurementUnit || 0;
  693. });
  694. this.currentRow.selectNum = selectNum;
  695. this.collapseVal = this.currentRow.informationCode;
  696. console.log(this.collapseVal);
  697. this.close();
  698. },
  699. open(...args) {
  700. // this.getTableData()
  701. },
  702. //获取仓库
  703. getwarehouseList() {
  704. post(this.apiUrl + "/warehouseGoodsshelves/select/warehouseList").then(
  705. (res) => {
  706. if (res.success) {
  707. this.warehouseList = res.data
  708. .filter((i) => !i.isDelete && !!i.status)
  709. .map((n) => {
  710. return {
  711. name: n.name,
  712. id: n.id,
  713. };
  714. });
  715. }
  716. }
  717. );
  718. },
  719. warehosueConfirm() {
  720. const obj = this.warehouseList[this.warehouseInfo?.detail?.value] || {};
  721. this.warehosueName = obj.name;
  722. this.warehouseId = obj.id;
  723. this.registerlist = [];
  724. this.showConfirm = false;
  725. },
  726. warehosueCancel() {
  727. this.warehosueVal = this.warehouseList.findIndex(
  728. (i) => i.id === this.warehouseId
  729. );
  730. this.showConfirm = false;
  731. },
  732. bindPickerChange(val) {
  733. this.warehosueVal = val?.detail?.value;
  734. if (
  735. this.warehouseId &&
  736. (this.registerlist.length > 0 ||
  737. this.registerlist.some((i) => i.tableData.length))
  738. ) {
  739. this.warehouseInfo = val;
  740. this.showConfirm = true;
  741. } else {
  742. const obj = this.warehouseList[val?.detail?.value] || {};
  743. this.warehosueName = obj.name;
  744. this.warehouseId = obj.id;
  745. this.registerlist = [];
  746. }
  747. },
  748. getTableData() {
  749. const params = {
  750. assetCode: this.currentRow.informationCode,
  751. searchKey: this.searchKey,
  752. warehouseId: this.warehouseId,
  753. };
  754. this.memo.push(
  755. ...this.tableData.filter((item) =>
  756. this.selectList.includes(item.onlyCode)
  757. )
  758. );
  759. this.selectList = [];
  760. get(
  761. this.apiUrl + "/outInWarehouse/getWarehouseActualDetail",
  762. params
  763. ).then((res) => {
  764. if (res?.success) {
  765. this.tableData = res.data;
  766. this.$nextTick(() => {
  767. this.tableData.map((i, idx) => {
  768. const index = this.memo.findIndex(
  769. (itm) => i.onlyCode === itm.onlyCode
  770. );
  771. if (index > -1) {
  772. this.selectList.push(i.onlyCode);
  773. this.memo.splice(index, 1);
  774. }
  775. });
  776. });
  777. }
  778. });
  779. },
  780. // 备品备件行选中事件
  781. rowclick(item, index) {
  782. this.chooseIndex = index;
  783. this.selectIndex = [index];
  784. this.chooseItem = item;
  785. },
  786. openPlus(item) {
  787. if (!this.warehouseId) {
  788. uni.showToast({
  789. title: "请选择仓库!",
  790. icon: "none",
  791. });
  792. return;
  793. }
  794. this.selectList = [];
  795. this.memo = uni.$u.deepClone(item.tableData);
  796. this.currentRow = item;
  797. this.popShow = true;
  798. this.getTableData();
  799. },
  800. timeConfirm() {
  801. this.timeShow = false;
  802. },
  803. timeCancel() {
  804. this.timeShow = false;
  805. },
  806. resetEqui() {
  807. this.pickerDeptShow = true;
  808. this.$refs.pickerDeptName.show();
  809. },
  810. handleChange(e) {
  811. let data = e.detail.value[e.detail.value.length - 1];
  812. this.classificationId = data.value;
  813. page = 1;
  814. isEnd = true;
  815. uni.showLoading({
  816. title: "数据加载中",
  817. });
  818. this.getList();
  819. },
  820. getTreeList() {
  821. postJ(this.apiUrl + "/classificationTree/list", [4]).then((res) => {
  822. // console.log(res)
  823. if (res.success) {
  824. this.treeList = res.data;
  825. this.pickerDeptShow = true;
  826. this.$refs.pickerDeptName.show();
  827. }
  828. });
  829. },
  830. getFirstList: function () {
  831. page = 1;
  832. isEnd = true;
  833. uni.showLoading({
  834. title: "数据加载中",
  835. });
  836. this.getList();
  837. },
  838. getMoreLists: function () {
  839. //获取更多数据
  840. page++;
  841. this.getList();
  842. },
  843. //获取列表数据
  844. getList() {
  845. post(this.apiUrl + "/classificationSpareParts/classificationSpare/list", {
  846. page,
  847. size,
  848. code: "",
  849. classificationId: this.classificationId,
  850. })
  851. .then((res) => {
  852. // console.log(res)
  853. let data = res.data.records;
  854. let pageTotal = res.data.pages;
  855. if (page === 1) {
  856. data.forEach((el) => {
  857. el.num = 0;
  858. });
  859. this.list = data;
  860. } else {
  861. data.forEach((element) => {
  862. element.num = 0;
  863. this.list.push(element);
  864. });
  865. }
  866. page < pageTotal ? (isEnd = false) : (isEnd = true);
  867. })
  868. .then(() => {
  869. uni.hideLoading();
  870. });
  871. },
  872. submit(data) {
  873. let list = data;
  874. let pickData = list.filter((item) => {
  875. return item.checked && !item.disabled && item.num > 0;
  876. });
  877. if (pickData.length == 0) {
  878. uni.showToast({
  879. title: "请选择备品备件数量",
  880. icon: "none",
  881. duration: 2000,
  882. });
  883. return;
  884. }
  885. this.$store.dispatch("maintenance/setSparepartIndex", this.index);
  886. this.$store.dispatch("maintenance/setSparepart", pickData);
  887. this.$store.dispatch("maintenance/setEquiIndex", this.equiIndex);
  888. this.back();
  889. },
  890. },
  891. };
  892. </script>
  893. <style lang="scss" scoped>
  894. .instance-list {
  895. background-color: #fff;
  896. font-size: 28rpx;
  897. .row {
  898. position: relative;
  899. padding: 10rpx 20rpx;
  900. & + .row {
  901. margin-top: 10rpx;
  902. }
  903. .uni-icons {
  904. position: absolute;
  905. top: 10rpx;
  906. right: 20rpx;
  907. }
  908. }
  909. }
  910. /deep/.uni-data-tree-input {
  911. display: none;
  912. }
  913. .no_data {
  914. position: fixed;
  915. top: 50%;
  916. left: 50%;
  917. transform: translate(-50%, -50%);
  918. .center {
  919. text-align: center;
  920. color: #555;
  921. font-size: $uni-font-size-base;
  922. }
  923. }
  924. .footer {
  925. position: fixed;
  926. display: flex;
  927. justify-content: space-between;
  928. align-items: center;
  929. bottom: 0;
  930. width: 100%;
  931. height: 90rpx;
  932. text-align: center;
  933. border-top: 1rpx solid #eeecec;
  934. background-color: #ffffff;
  935. .bottom {
  936. font-size: $uni-font-size-lg;
  937. margin-left: 20rpx;
  938. .select-all {
  939. color: $j-primary-green;
  940. }
  941. }
  942. .footer-span-btn {
  943. height: 30rpx;
  944. line-height: 30rpx;
  945. font-size: $uni-font-size-lg;
  946. color: #ffffff;
  947. margin-right: 20rpx;
  948. padding: 10rpx 20rpx;
  949. text-align: center;
  950. background-color: $j-primary-green;
  951. border-radius: 40rpx;
  952. }
  953. }
  954. .footer-right {
  955. justify-content: flex-end;
  956. }
  957. .sparepart-container {
  958. padding: 40rpx 20rpx;
  959. margin-bottom: 120rpx;
  960. .infos {
  961. border: 1rpx solid rgba(242, 242, 242, 1);
  962. padding: 0 20rpx;
  963. .col {
  964. height: 60rpx;
  965. line-height: 60rpx;
  966. display: flex;
  967. align-items: stretch;
  968. font-size: 28rpx;
  969. & + .col {
  970. margin-top: 4rpx;
  971. }
  972. .label {
  973. display: inline-block;
  974. width: 200rpx;
  975. padding-right: 20rpx;
  976. text-align: right;
  977. background-color: rgba(215, 215, 215, 1);
  978. }
  979. .content {
  980. flex: 1;
  981. background-color: rgba(242, 242, 242, 1);
  982. padding-left: 8rpx;
  983. border: 1rpx solid rgba(215, 215, 215, 1);
  984. }
  985. }
  986. }
  987. .detail-title {
  988. font-size: 34rpx;
  989. padding: 20rpx 0;
  990. margin-top: 10rpx;
  991. display: flex;
  992. justify-content: space-between;
  993. .u-button {
  994. width: 180rpx;
  995. margin: 0;
  996. }
  997. }
  998. .detail-content {
  999. border: 1rpx solid rgba(242, 242, 242, 1);
  1000. min-height: 50vh;
  1001. padding-bottom: 100rpx;
  1002. .col {
  1003. font-size: 30rpx;
  1004. border-bottom: 1rpx solid rgba(242, 242, 242, 1);
  1005. display: flex;
  1006. padding: 10rpx;
  1007. align-items: center;
  1008. justify-content: space-between;
  1009. background-color: rgba(242, 242, 242, 0.372549019607843);
  1010. }
  1011. .plus {
  1012. width: 40rpx;
  1013. height: 40rpx;
  1014. line-height: 38rpx;
  1015. text-align: center;
  1016. background-color: $j-primary-border-green;
  1017. color: #fff;
  1018. margin: 16rpx 0 0 16rpx;
  1019. }
  1020. }
  1021. /deep/.u-number-box {
  1022. .u-number-box__minus,
  1023. .u-number-box__plus,
  1024. .u-number-box__input {
  1025. font-size: 30rpx;
  1026. height: 1.6em !important;
  1027. }
  1028. .u-number-box__input {
  1029. width: 2em !important;
  1030. }
  1031. .u-number-box__minus,
  1032. .u-number-box__plus {
  1033. background-color: $j-primary-border-green !important;
  1034. .u-icon__icon {
  1035. color: #fff !important;
  1036. }
  1037. }
  1038. }
  1039. }
  1040. .select-container {
  1041. // height:60vh;
  1042. .title {
  1043. height: 70rpx;
  1044. line-height: 70rpx;
  1045. text-align: center;
  1046. background-color: $j-primary-border-green;
  1047. font-weight: bold;
  1048. position: relative;
  1049. font-size: 28rpx;
  1050. color: #fff;
  1051. .btn-box {
  1052. position: absolute;
  1053. top: 50%;
  1054. right: 10rpx;
  1055. transform: translateY(-50%);
  1056. }
  1057. .btn {
  1058. width: 60rpx;
  1059. height: 32rpx;
  1060. display: inline-block;
  1061. font-size: 28rpx;
  1062. border: 1px solid #fff;
  1063. text-align: center;
  1064. line-height: 30rpx;
  1065. }
  1066. }
  1067. input {
  1068. display: block;
  1069. margin: 8rpx auto;
  1070. width: 720rpx;
  1071. height: 72rpx;
  1072. border: 1rpx solid rgb(153, 153, 153);
  1073. padding-left: 8rpx;
  1074. }
  1075. /deep/.uni-table {
  1076. margin-top: 10rpx;
  1077. // min-width: 100% !important;
  1078. // max-width: 100%;
  1079. }
  1080. .uni-table-th-row {
  1081. padding: 24rpx 0 !important;
  1082. }
  1083. .uni-table-td,
  1084. .uni-table-th {
  1085. font-size: 28rpx;
  1086. }
  1087. .uni-table-th {
  1088. background-color: rgba(242, 242, 242, 1);
  1089. padding: 24rpx 0 !important;
  1090. }
  1091. .table-wrapper {
  1092. height: 75vh;
  1093. overflow: auto;
  1094. padding: 20rpx;
  1095. }
  1096. }
  1097. .sparepart-footer {
  1098. width: 100%;
  1099. height: 80px;
  1100. display: flex;
  1101. align-items: center;
  1102. justify-content: space-around;
  1103. position: fixed;
  1104. bottom: 0;
  1105. background: #fff;
  1106. button {
  1107. width: 300rpx;
  1108. height: 80rpx;
  1109. line-height: 80rpx;
  1110. &.primary {
  1111. background-color: $j-primary-border-green;
  1112. color: #fff;
  1113. }
  1114. }
  1115. }
  1116. .listContent {
  1117. flex: 1;
  1118. overflow: auto;
  1119. padding-bottom: 125rpx;
  1120. .self-table-tr {
  1121. padding: 5rpx 0;
  1122. border-bottom: 1rpx solid #ccc;
  1123. }
  1124. }
  1125. .self-table-header {
  1126. padding: 20rpx;
  1127. border-bottom: 1rpx solid #ccc;
  1128. }
  1129. .self-table-tr,
  1130. .self-table-header {
  1131. font-size: 28rpx;
  1132. display: flex;
  1133. justify-content: space-between;
  1134. flex-wrap: wrap;
  1135. .table-date,
  1136. .table-batch,
  1137. .table-code {
  1138. box-sizing: border-box;
  1139. width: 27%;
  1140. padding: 0 5rpx;
  1141. word-break: break-all;
  1142. }
  1143. .table-code {
  1144. width: 50%;
  1145. }
  1146. .table-date {
  1147. width: 37%;
  1148. }
  1149. .other-info {
  1150. color: #aaa;
  1151. width: 100%;
  1152. display: flex;
  1153. justify-content: space-between;
  1154. font-size: 28rpx;
  1155. flex-wrap: wrap;
  1156. > view {
  1157. margin-bottom: 10rpx;
  1158. }
  1159. }
  1160. .checked {
  1161. width: 100%;
  1162. display: flex;
  1163. justify-content: flex-end;
  1164. }
  1165. }
  1166. </style>