index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <van-nav-bar :title="$t('inventoryCount.name')" left-text="" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
  3. <!-- <template #right> {{ $t("common.add") }} </template> -->
  4. </van-nav-bar>
  5. <div style="display:flex">
  6. <van-dropdown-menu>
  7. <van-dropdown-item v-model="req.warehouseId" :options="warehouseList" @change="changeWarehouseId" />
  8. </van-dropdown-menu>
  9. <van-search v-model="req.keyword" style="flex:1" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
  10. </div>
  11. <van-tabs v-model:active="active" @change="handleChangeTab">
  12. <van-tab :title="'物资盘点'" name="first"></van-tab>
  13. <van-tab :title="'盘点记录'" name="second"></van-tab>
  14. <van-tab :title="'历史记录'" name="three"></van-tab>
  15. </van-tabs>
  16. <div style="padding:0 16px" v-if="active!='three'">
  17. <table class="table">
  18. <thead>
  19. <tr>
  20. <th style="width:70%;text-align: left;">物品信息</th>
  21. <th style="width:30%">本次盘点累计</th>
  22. </tr>
  23. </thead>
  24. </table>
  25. </div>
  26. <div style="overflow-y:auto"
  27. :style="{height:active!='three'? !deviceStore.isIosSysteme?'calc(100vh - 258px)':'calc(100vh - 278px)':!deviceStore.isIosSysteme?'calc(100vh - 194px)':'calc(100vh - 214px)'}">
  28. <van-pull-refresh v-model="loading" @refresh="onRefresh">
  29. <div class="list">
  30. <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="getList" style="margin-bottom: 60px">
  31. <commonList :data="listData" @onClick="toDtl" :config="listConfig" v-if="active=='three'">
  32. <template #inventoryResult="{ row }">
  33. <div>
  34. <span v-if="row.result == 0">正常</span>
  35. <span style="color: red" v-else>异常</span>
  36. </div>
  37. </template>
  38. </commonList>
  39. <div v-else style="margin-bottom:10px">
  40. <div v-for="(row,index) in listData" :key="row.id" class="main-box">
  41. <div style="display:flex;align-items:center">
  42. <div style="width:70%">
  43. <div>
  44. 仓库名称:{{row.warehouseName}}
  45. </div>
  46. <div style="margin-top:3px">
  47. 物品编码:{{row.productCustomCode}}
  48. </div>
  49. <div style="margin-top:3px">
  50. 物品名称:{{row.productName}}
  51. </div>
  52. <div style="margin-top:3px">
  53. 物品规格:{{row.productSpec}}
  54. </div>
  55. <div style="margin-top:3px">
  56. 可用库存:{{row.quantity}}
  57. </div>
  58. </div>
  59. <div style="width:30%;color:red;text-align:center">
  60. {{row.checkQuantity}}
  61. </div>
  62. </div>
  63. <!-- style="border-bottom:1px solid #f1f1f1;" -->
  64. <div>
  65. <div style="padding:0 6px">
  66. <div style="text-align:center;color:#b7b0b0;margin-bottom:10px" @click="row.isArrow =!row.isArrow">
  67. <span>在线盘点登记</span>
  68. <van-icon :name="!row.isArrow ?'arrow-down':'arrow-up'" style="margin-left:5px" />
  69. </div>
  70. <div v-show="row.isArrow" style="margin-top:5px;margin-bottom:10px">
  71. <div style="display:flex;margin-bottom:8px ;align-items:center">
  72. <van-field v-model="row.addQuantity" type="digit" label="" class="aa" placeholder="请输入临时盘点数量"
  73. style="background-color:#f7f7f7;" />
  74. <van-button type="success" size="small" style="width:60px;margin-left:10px" @click="handleStag(row,index)">暂存</van-button>
  75. </div>
  76. <div>
  77. <table class="tableTwo">
  78. <thead>
  79. <tr>
  80. <th>时间</th>
  81. <th style="width:70px">盘点数量</th>
  82. <th style="width:50px">操作</th>
  83. </tr>
  84. </thead>
  85. <tbody>
  86. <tr v-for="(sonRow,sonIndex) in row.stockCheckRegisterList" :key="sonIndex">
  87. <td>
  88. {{sonRow.createTime}}
  89. </td>
  90. <td>
  91. {{sonRow.checkQuantity}}
  92. </td>
  93. <td>
  94. <span style="color:#409EFF;cursor:pointer" v-if="sonRow.status !=2" @click="handleDelete(row,index,sonRow)">删除</span>
  95. </td>
  96. </tr>
  97. </tbody>
  98. </table>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </van-list>
  106. </div>
  107. </van-pull-refresh>
  108. </div>
  109. <div style="padding:0 16px;margin-top:5px;" v-if="active!='three'">
  110. <van-button type="primary" round block @click="onSubmit()" style="height:30px">提交</van-button>
  111. </div>
  112. </template>
  113. <script setup>
  114. import { ref, getCurrentInstance } from "vue";
  115. import commonList from "@/components/common-list.vue";
  116. import { showSuccessToast, showFailToast } from "vant";
  117. import { parseTime } from "@/utils/ruoyi";
  118. import useDeviceStore from "@/store/device";
  119. const deviceStore = useDeviceStore();
  120. const proxy = getCurrentInstance().proxy;
  121. const onClickLeft = () => proxy.$router.push("/main/working");
  122. const req = ref({
  123. pageNum: 1,
  124. keyword: "",
  125. warehouseId: "",
  126. isCheckRegister: "",
  127. });
  128. const warehouseId = ref("");
  129. const warehouseList = ref([{ text: "全部仓库", value: "" }]);
  130. const active = ref("first");
  131. const finished = ref(false);
  132. const onRefresh = () => {
  133. req.value.pageNum = 1;
  134. finished.value = false;
  135. getList("refresh");
  136. };
  137. const loading = ref(false);
  138. const listData = ref([]);
  139. const getList = (type) => {
  140. loading.value = true;
  141. proxy
  142. .post(requestUrl.value, req.value)
  143. .then((res) => {
  144. if (active.value != "three") {
  145. res.data.rows.map((x) => {
  146. x.addQuantity = "";
  147. if (x.stockCheckRegisterList && x.stockCheckRegisterList.length > 0) {
  148. x.checkQuantity = x.stockCheckRegisterList.reduce(
  149. (total, x) => (total += Number(x.checkQuantity)),
  150. 0
  151. );
  152. } else {
  153. x.checkQuantity = 0;
  154. }
  155. });
  156. }
  157. listData.value =
  158. type === "refresh"
  159. ? res.data.rows
  160. : listData.value.concat(res.data.rows);
  161. if (req.value.pageNum * 10 >= res.data.total) {
  162. finished.value = true;
  163. }
  164. req.value.pageNum++;
  165. loading.value = false;
  166. })
  167. .catch(() => {
  168. loading.value = false;
  169. });
  170. };
  171. const toDtl = (row) => {
  172. proxy.$router.push({
  173. path: "/main/inventoryCountAdd",
  174. query: {
  175. id: row.id,
  176. },
  177. });
  178. };
  179. const onClickRight = () => {
  180. proxy.$router.push({
  181. path: "/main/inventoryCountAdd",
  182. query: {},
  183. });
  184. };
  185. const listConfig = ref([
  186. {
  187. label: "盘点单号",
  188. prop: "code",
  189. },
  190. {
  191. label: "仓库名称",
  192. prop: "warehouseName",
  193. },
  194. {
  195. label: "盘点时间",
  196. prop: "createTime",
  197. },
  198. {
  199. label: "盘点人",
  200. prop: "userName",
  201. },
  202. {
  203. label: "盘点物品数",
  204. prop: "totalNum",
  205. },
  206. {
  207. label: "正常物品数",
  208. prop: "normalNum",
  209. },
  210. {
  211. label: "异常物品数",
  212. prop: "anomalyNum",
  213. },
  214. {
  215. type: "slot",
  216. label: "盘点结论",
  217. slotName: "inventoryResult",
  218. },
  219. ]);
  220. const requestUrl = ref("/stockCheck/stockProductPage");
  221. const handleChangeTab = (val) => {
  222. if (val == "first") {
  223. requestUrl.value = "/stockCheck/stockProductPage";
  224. req.value.isCheckRegister = "";
  225. } else if (val == "second") {
  226. requestUrl.value = "/stockCheck/stockProductPage";
  227. req.value.isCheckRegister = "1";
  228. } else {
  229. requestUrl.value = "/stockCheck/page";
  230. req.value.isCheckRegister = "";
  231. }
  232. req.value.pageNum = 1;
  233. listData.value = [];
  234. getList();
  235. };
  236. const changeWarehouseId = (val) => {
  237. req.value = {
  238. pageNum: 1,
  239. keyword: "",
  240. warehouseId: val,
  241. isCheckRegister: "",
  242. };
  243. listData.value = [];
  244. getList();
  245. };
  246. const getDict = () => {
  247. proxy.post("/warehouse/page", { pageNum: 1, pageSize: 999 }).then((res) => {
  248. warehouseList.value = [
  249. ...warehouseList.value,
  250. ...res.data.rows.map((x) => ({ text: x.name, value: x.id })),
  251. ];
  252. });
  253. };
  254. getDict();
  255. const getSonList = (query, index) => {
  256. proxy.post("/stockCheckRegister/list", query).then((res) => {
  257. listData.value[index].stockCheckRegisterList = res.data;
  258. listData.value[index].checkQuantity = res.data
  259. .filter((x) => x.status != 2)
  260. .reduce((total, y) => (total += Number(y.checkQuantity)), 0);
  261. });
  262. };
  263. const handleStag = (row, index) => {
  264. if (Number(row.addQuantity) > 0) {
  265. let obj = {
  266. stockId: row.id,
  267. warehouseId: row.warehouseId,
  268. productId: row.productId,
  269. createTime: parseTime(new Date()),
  270. // quantity: row.quantity,
  271. checkQuantity: Number(row.addQuantity),
  272. status: 0,
  273. };
  274. proxy.post("/stockCheckRegister/add", obj).then((res) => {
  275. row.addQuantity = "";
  276. let query = {
  277. stockId: row.id,
  278. warehouseId: row.warehouseId,
  279. productId: row.productId,
  280. };
  281. getSonList(query, index);
  282. return showSuccessToast("暂存成功");
  283. });
  284. } else {
  285. return showFailToast("数量必须大于0");
  286. }
  287. };
  288. const handleDelete = (row, index, sonRow) => {
  289. let query = {
  290. stockId: row.id,
  291. warehouseId: row.warehouseId,
  292. productId: row.productId,
  293. };
  294. proxy.post("/stockCheckRegister/delete", { id: sonRow.id }).then((res) => {
  295. getSonList(query, index);
  296. return showSuccessToast("删除成功");
  297. });
  298. };
  299. const onSubmit = () => {
  300. proxy.post("/stockCheck/submitAll").then(
  301. (res) => {
  302. showSuccessToast("操作成功");
  303. onRefresh();
  304. },
  305. (err) => {
  306. return showFailToast(err.message);
  307. }
  308. );
  309. };
  310. </script>
  311. <style lang="scss" scoped>
  312. * {
  313. font-size: 11px;
  314. }
  315. .list {
  316. min-height: 100%;
  317. }
  318. .main-box {
  319. padding: 12px 16px 0 16px;
  320. background: #fff;
  321. border-bottom: 1px solid #f1f1f1;
  322. }
  323. .table {
  324. border-collapse: collapse;
  325. border-spacing: 0;
  326. width: 100%;
  327. border-color: #ebeef5;
  328. color: #606266;
  329. thead tr th {
  330. padding: 6px 2px;
  331. text-align: center;
  332. color: #000;
  333. }
  334. td {
  335. text-align: center;
  336. padding: 6px 2px;
  337. // height: 40px;
  338. height: 30px;
  339. }
  340. }
  341. .tableTwo {
  342. border-collapse: collapse;
  343. border-spacing: 0;
  344. width: 100%;
  345. background-color: #f7f7f7;
  346. color: #606266;
  347. thead tr th {
  348. text-align: center;
  349. padding: 6px 2px;
  350. height: 20px;
  351. color: #000;
  352. }
  353. td {
  354. text-align: center;
  355. padding: 6px 2px;
  356. height: 30px;
  357. }
  358. }
  359. :deep(.van-dropdown-menu__bar) {
  360. box-shadow: none !important;
  361. height: 54px !important;
  362. }
  363. :deep(.van-field.aa) {
  364. padding: 5px 10px;
  365. }
  366. </style>