add.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <div class="form">
  3. <van-nav-bar :title="$t('waitInbound.name')" :left-text="$t('common.back')" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
  4. <template #right>
  5. <van-button plain type="primary" size="small">多货登记</van-button> </template>
  6. </van-nav-bar>
  7. <van-tabs v-model:active="active">
  8. <van-tab title="入库明细" :name="0" />
  9. <van-tab title="基本信息" :name="1" />
  10. </van-tabs>
  11. <van-form @submit="onSubmit" @failed="onFailed" label-align="top" style="margin-top: 20px">
  12. <van-cell-group inset v-show="active==1">
  13. <van-field v-model="formData.businessTypeName" readonly :label="$t('waitInbound.dataSource')" />
  14. <van-field v-model="formData.businessCode" readonly label="入库单号" />
  15. <van-field v-model="formData.code" readonly label="物流信息" />
  16. <van-field v-model="formData.warehouseName" is-link label="仓库名称" readonly :placeholder="'请选择仓库名称'" @click="typeModal = true"
  17. :rules="[{ required: true, message: '请选择仓库名称'}]" required />
  18. <van-field v-model="formData.arrivalRemark" label="到货物流备注" type="textarea" />
  19. <van-popup v-model:show="typeModal" round position="bottom">
  20. <van-picker :columns="columns" @cancel="typeModal = false" @confirm="onConfirm" />
  21. </van-popup>
  22. </van-cell-group>
  23. <!-- overflow-x: auto;width:calc(100% - 20px) -->
  24. <van-cell-group inset v-show="active==0" style="padding:10px;">
  25. <van-search v-model="keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onSearch" style="padding:0px" />
  26. <table class="table">
  27. <thead>
  28. <tr>
  29. <th style="width:46%;text-align:left;">物品信息</th>
  30. <th style="width:13%">采购<div style="width:0px;height:0px"></div>数量
  31. </th>
  32. <th style="width:13%">本次<div style="width:0px;height:0px"></div>发货
  33. </th>
  34. <th style="width:15%">已入库</th>
  35. <th style="width:13%">累计<div style="width:0px;height:0px"></div>清点
  36. </th>
  37. </tr>
  38. </thead>
  39. </table>
  40. <div style="height:calc(100vh - 280px);overflow-y:auto"
  41. :style="{height:!deviceStore.isIosSysteme?'calc(100vh - 280px)':'calc(100vh - 300px)'}">
  42. <table class="table" v-if="!keyword">
  43. <tbody>
  44. <template v-for="(row,index) in formData.stockWaitDetailsList" :key="row.id">
  45. <div style="height:10px">
  46. </div>
  47. <tr>
  48. <td style="text-align:left;width:46%">
  49. <div>编码:{{row.productCustomCode}}</div>
  50. <div style="margin-top:3px">名称:{{row.productName}}</div>
  51. <div style="margin-top:3px">规格:{{row.productSpec}}</div>
  52. </td>
  53. <td style="width:13%">
  54. <div>{{row.purchaseQuantity}}</div>
  55. </td>
  56. <td style="width:13%">
  57. <div>{{row.arrivalQuantity}}</div>
  58. </td>
  59. <td style="width:15%">
  60. <div>{{row.receiptQuantity}}</div>
  61. </td>
  62. <td style="width:13%">
  63. <div style="color:red">{{row.quantity}}</div>
  64. </td>
  65. </tr>
  66. <tr style="border-bottom:1px solid #f1f1f1;">
  67. <td colspan="5" style="padding:0 6px">
  68. <div style="text-align:center;color:#b7b0b0;margin-bottom:10px" @click="row.isArrow =!row.isArrow">
  69. <span>在线清点登记</span>
  70. <van-icon :name="!row.isArrow ?'arrow-down':'arrow-up'" style="margin-left:5px" />
  71. </div>
  72. <div v-show="row.isArrow" style="margin-top:5px;margin-bottom:10px">
  73. <div style="display:flex;margin-bottom:8px ;align-items:center">
  74. <van-field v-model="row.addQuantity" type="digit" label="" placeholder="请输入临时清点数量" style="background-color:#f7f7f7;" />
  75. <van-button type="success" size="small" style="width:60px;margin-left:10px" @click="handleStag(row,index)">暂存</van-button>
  76. </div>
  77. <div>
  78. <table class="tableTwo">
  79. <thead>
  80. <tr>
  81. <th>时间</th>
  82. <th style="width:70px">清点数量</th>
  83. <th style="width:70px">提交状态</th>
  84. <th style="width:50px">操作</th>
  85. </tr>
  86. </thead>
  87. <tbody>
  88. <tr v-for="(sonRow,sonIndex) in row.stockWaitDetailsCheckList" :key="sonIndex">
  89. <td>
  90. {{sonRow.createTime}}
  91. </td>
  92. <td>
  93. {{sonRow.quantity}}
  94. </td>
  95. <td>
  96. {{sonRow.status==2?'已提交':'未提交'}}
  97. </td>
  98. <td>
  99. <span style="color:#409EFF;cursor:pointer" v-if="sonRow.status !=2" @click="handleDelete(row,index,sonRow)">删除</span>
  100. </td>
  101. </tr>
  102. </tbody>
  103. </table>
  104. </div>
  105. </div>
  106. </td>
  107. </tr>
  108. </template>
  109. </tbody>
  110. </table>
  111. <table class="table" v-else>
  112. <tbody>
  113. <template v-for="(row,index) in formData.stockWaitDetailsListCopy" :key="row.id">
  114. <div style="height:10px">
  115. </div>
  116. <tr>
  117. <td style="text-align:left;width:31%">
  118. <div>编码:{{row.productCustomCode}}</div>
  119. <div>名称:{{row.productName}}</div>
  120. <div>规格:{{row.productSpec}}</div>
  121. </td>
  122. <td style="width:18%">
  123. <div>{{row.purchaseQuantity}}</div>
  124. </td>
  125. <td style="width:18%">
  126. <div>{{row.arrivalQuantity}}</div>
  127. </td>
  128. <td style="width:15%">
  129. <div>{{row.receiptQuantity}}</div>
  130. </td>
  131. <td style="width:18%">
  132. <div style="color:red">{{row.quantity}}</div>
  133. </td>
  134. </tr>
  135. <tr style="border-bottom:1px solid #f1f1f1;">
  136. <td colspan="5" style="padding:0 6px">
  137. <div style="text-align:center;color:#b7b0b0;margin-bottom:10px" @click="row.isArrow =!row.isArrow">
  138. <span>在线清点登记</span>
  139. <van-icon :name="!row.isArrow ?'arrow-down':'arrow-up'" style="margin-left:5px" />
  140. </div>
  141. <div v-show="row.isArrow" style="margin-top:5px;margin-bottom:10px">
  142. <div style="display:flex;margin-bottom:8px ;align-items:center">
  143. <van-field v-model="row.addQuantity" type="digit" label="" placeholder="请输入临时清点数量" style="background-color:#f7f7f7;" />
  144. <van-button type="success" size="small" style="width:60px;margin-left:10px" @click="handleStag(row,index)">暂存</van-button>
  145. </div>
  146. <div>
  147. <table class="tableTwo">
  148. <thead>
  149. <tr>
  150. <th>时间</th>
  151. <th style="width:70px">清点数量</th>
  152. <th style="width:70px">提交状态</th>
  153. <th style="width:50px">操作</th>
  154. </tr>
  155. </thead>
  156. <tbody>
  157. <tr v-for="(sonRow,sonIndex) in row.stockWaitDetailsCheckList" :key="sonIndex">
  158. <td>
  159. {{sonRow.createTime}}
  160. </td>
  161. <td>
  162. {{sonRow.quantity}}
  163. </td>
  164. <td>
  165. {{sonRow.status==2?'已提交':'未提交'}}
  166. </td>
  167. <td>
  168. <span style="color:#409EFF;cursor:pointer" v-if="sonRow.status !=2" @click="handleDelete(row,index,sonRow)">删除</span>
  169. </td>
  170. </tr>
  171. </tbody>
  172. </table>
  173. </div>
  174. </div>
  175. </td>
  176. </tr>
  177. </template>
  178. </tbody>
  179. </table>
  180. </div>
  181. </van-cell-group>
  182. <div style="margin-top: 5px">
  183. <van-button round block type="primary" native-type="submit" style="height:30px">
  184. {{$t('common.submit')}}
  185. </van-button>
  186. </div>
  187. </van-form>
  188. </div>
  189. </template>
  190. <script setup>
  191. import { ref, getCurrentInstance, onMounted } from "vue";
  192. import { showSuccessToast, showFailToast } from "vant";
  193. import { useRoute } from "vue-router";
  194. import { parseTime } from "@/utils/ruoyi";
  195. import useDeviceStore from "@/store/device";
  196. const deviceStore = useDeviceStore();
  197. const proxy = getCurrentInstance().proxy;
  198. const active = ref(0);
  199. const route = useRoute();
  200. const typeModal = ref(false);
  201. const formData = ref({});
  202. const getDict = () => {
  203. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 9999 }).then((res) => {
  204. columns.value = res.data.rows.map((item) => {
  205. return {
  206. text: item.name,
  207. value: item.id,
  208. };
  209. });
  210. });
  211. };
  212. const getDetails = (id) => {
  213. proxy.post("/stockWait/detail", { id }).then((res) => {
  214. res.data.inQuantity = res.data.quantity;
  215. formData.value = res.data;
  216. });
  217. };
  218. const columns = ref([]);
  219. const onConfirm = ({ selectedOptions }) => {
  220. formData.value.warehouseId = selectedOptions[0].value;
  221. formData.value.warehouseName = selectedOptions[0].text;
  222. typeModal.value = false;
  223. };
  224. const onClickLeft = () => history.back();
  225. const onSubmit = () => {
  226. const list = formData.value.stockWaitDetailsList;
  227. const total = list.reduce((total, x) => (total += Number(x.quantity)), 0);
  228. if (!(total > 0)) {
  229. return showFailToast("清点累计不能为0");
  230. }
  231. proxy.post("/stockWait/addByWdly", formData.value).then(
  232. (res) => {
  233. setTimeout(() => {
  234. showSuccessToast(proxy.$t("manualInbound.warehousingSuccess"));
  235. proxy.$router.push("/main/waitInbound");
  236. }, 500);
  237. },
  238. (err) => {
  239. return showFailToast(err.message);
  240. }
  241. );
  242. };
  243. const onFailed = () => {
  244. return showFailToast("数据未填完整");
  245. };
  246. const businessType = ref([
  247. { label: "线边回仓", value: "1" },
  248. { label: "完工入库", value: "2" },
  249. { label: "采购到货", value: "3" },
  250. { label: "退货出库", value: "4" },
  251. ]);
  252. onMounted(() => {
  253. if (route.query && route.query.id) {
  254. proxy
  255. .post("/stockWait/detailByWdly", { id: route.query.id })
  256. .then((data) => {
  257. let res = data.data;
  258. const json = res.victoriatouristJson
  259. ? JSON.parse(res.victoriatouristJson)
  260. : {};
  261. formData.value = {
  262. id: route.query.id,
  263. type: "1",
  264. businessCode: res.businessCode,
  265. businessType: res.businessType + "",
  266. businessTypeName: proxy.dictValueLabel(
  267. res.businessType,
  268. businessType.value
  269. ),
  270. warehouseId: "",
  271. code: json.logisticsCompanyName + "( " + json.code + " )",
  272. stockWaitDetailsList: res.stockWaitDetailsList.map((x) => ({
  273. ...x,
  274. arrivalQuantity: x.quantity,
  275. quantity: x.stockWaitDetailsCheckList
  276. ? x.stockWaitDetailsCheckList
  277. .filter((x) => x.status != 2)
  278. .reduce((total, y) => (total += Number(y.quantity)), 0)
  279. : 0,
  280. isArrow: false,
  281. stockWaitDetailsCheckList: x.stockWaitDetailsCheckList || [],
  282. })),
  283. stockWaitDetailsListCopy: [],
  284. };
  285. });
  286. }
  287. getDict();
  288. });
  289. const getSonList = (query, index) => {
  290. proxy.post("/stockWaitDetailsCheck/list", query).then((res) => {
  291. if (keyword.value) {
  292. formData.value.stockWaitDetailsListCopy[index].stockWaitDetailsCheckList =
  293. res.data;
  294. formData.value.stockWaitDetailsListCopy[index].quantity = res.data
  295. .filter((x) => x.status != 2)
  296. .reduce((total, y) => (total += Number(y.quantity)), 0);
  297. // 修改数据
  298. let id = formData.value.stockWaitDetailsListCopy[index].id;
  299. if (id) {
  300. let noKeywordIndex = formData.value.stockWaitDetailsList.findIndex(
  301. (x) => x.id == id
  302. );
  303. if (noKeywordIndex != -1) {
  304. formData.value.stockWaitDetailsList[
  305. noKeywordIndex
  306. ].stockWaitDetailsCheckList = res.data;
  307. formData.value.stockWaitDetailsList[noKeywordIndex].quantity =
  308. res.data
  309. .filter((x) => x.status != 2)
  310. .reduce((total, y) => (total += Number(y.quantity)), 0);
  311. }
  312. }
  313. } else {
  314. formData.value.stockWaitDetailsList[index].stockWaitDetailsCheckList =
  315. res.data;
  316. formData.value.stockWaitDetailsList[index].quantity = res.data
  317. .filter((x) => x.status != 2)
  318. .reduce((total, y) => (total += Number(y.quantity)), 0);
  319. }
  320. });
  321. };
  322. const handleStag = (row, index) => {
  323. if (Number(row.addQuantity) > 0) {
  324. let obj = {
  325. stockWaitId: formData.value.id,
  326. stockWaitDetailsId: row.id,
  327. createTime: parseTime(new Date()),
  328. quantity: Number(row.addQuantity),
  329. status: 0,
  330. };
  331. // row.stockWaitDetailsCheckList.push(obj);
  332. proxy.post("/stockWaitDetailsCheck/add", obj).then((res) => {
  333. row.addQuantity = "";
  334. getSonList({ stockWaitDetailsId: row.id }, index);
  335. return showSuccessToast("暂存成功");
  336. });
  337. } else {
  338. return showFailToast("数量必须大于0");
  339. }
  340. };
  341. const handleDelete = (row, index, sonRow) => {
  342. // formData.value.stockWaitDetailsList[index].stockWaitDetailsCheckList.splice(
  343. // sonIndex,
  344. // 1
  345. // );
  346. proxy.post("/stockWaitDetailsCheck/delete", { id: sonRow.id }).then((res) => {
  347. getSonList({ stockWaitDetailsId: row.id }, index);
  348. return showSuccessToast("删除成功");
  349. });
  350. };
  351. const onClickRight = () => {
  352. proxy.$router.push({
  353. path: "/main/manyGoods",
  354. query: {
  355. id: formData.value.id,
  356. businessTypeName: formData.value.businessTypeName,
  357. businessCode: formData.value.businessCode,
  358. code: formData.value.code,
  359. },
  360. });
  361. };
  362. const keyword = ref("");
  363. const onSearch = (val) => {
  364. formData.value.stockWaitDetailsListCopy = [];
  365. let list = formData.value.stockWaitDetailsList;
  366. for (let i = 0; i < list.length; i++) {
  367. const row = list[i];
  368. if (
  369. row.productCustomCode.indexOf(val) != -1 ||
  370. row.productName.indexOf(val) != -1 ||
  371. row.productSpec.indexOf(val) != -1
  372. ) {
  373. formData.value.stockWaitDetailsListCopy.push({ ...row });
  374. }
  375. }
  376. };
  377. </script>
  378. <style lang="scss" scoped>
  379. * {
  380. font-size: 11px;
  381. }
  382. :deep(.van-search__field) {
  383. display: flex;
  384. .van-field__label--top {
  385. width: 20px;
  386. margin-bottom: 0px;
  387. }
  388. }
  389. .row {
  390. display: flex;
  391. padding: 5px 10px 0 10px;
  392. justify-content: space-between;
  393. align-items: center;
  394. .title {
  395. flex: 1;
  396. }
  397. .delete {
  398. width: 20px;
  399. cursor: pointer;
  400. text-align: center;
  401. }
  402. }
  403. .table {
  404. border-collapse: collapse;
  405. border-spacing: 0;
  406. width: 100%;
  407. border-color: #ebeef5;
  408. color: #606266;
  409. thead tr th {
  410. padding: 6px 2px;
  411. text-align: center;
  412. color: #000;
  413. }
  414. td {
  415. text-align: center;
  416. padding: 6px 2px;
  417. // height: 40px;
  418. height: 30px;
  419. }
  420. }
  421. .tableTwo {
  422. border-collapse: collapse;
  423. border-spacing: 0;
  424. width: 100%;
  425. background-color: #f7f7f7;
  426. color: #606266;
  427. thead tr th {
  428. text-align: center;
  429. padding: 6px 2px;
  430. height: 30px;
  431. color: #000;
  432. }
  433. td {
  434. text-align: center;
  435. padding: 6px 2px;
  436. height: 30px;
  437. }
  438. }
  439. </style>