index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <div class="stockWarning pagePadding">
  3. <div
  4. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  5. >
  6. <div style="width: 100%">
  7. <el-row style="padding: 15px 0 0 0px">
  8. <el-col :span="12" style="width: 290px;">
  9. <search-work-company
  10. :value="parmValue.supplierNo"
  11. :names="supplier_name"
  12. :size="searchSize"
  13. :is-detail="id !== 'add'"
  14. :disabled="isDetail"
  15. :placeholder="'业务公司'"
  16. @searchChange="supplierChange"
  17. />
  18. </el-col>
  19. <el-col :span="12" style="width: 300px; padding-left: 10px">
  20. <search-supplier
  21. :size="searchSize"
  22. :placeholder="'供应商公司'"
  23. :value="parmValue.supplier_code"
  24. @searchChange="selectSupplier"
  25. />
  26. </el-col>
  27. <el-col :span="12" style="width: 240px; padding-left: 10px">
  28. <search-stock
  29. :isDetail="true"
  30. :size="searchSize"
  31. :value="parmValue.stock_code"
  32. :disabled="supplier_code === ''"
  33. :placeholder="'出库仓库'"
  34. :isRelation="true"
  35. :companyCode="supplier_code"
  36. :names="''"
  37. @searchChange="selectStock"
  38. />
  39. </el-col>
  40. </el-row>
  41. </div>
  42. <div class="stock-survey clear">
  43. <el-row v-for="item in stock_list" :key="item.id" style="float: left">
  44. <el-col :span="24" class="card">
  45. <el-card shadow="always">
  46. <i :class="item.icon" class="icon"></i>
  47. <countTo
  48. style="display: block"
  49. :startVal="0"
  50. :endVal="item.endVal"
  51. :duration="3000"
  52. ></countTo>
  53. <p style="margin-top: 5px">{{ item.label }}</p>
  54. </el-card>
  55. </el-col>
  56. </el-row>
  57. </div>
  58. <ex-table
  59. v-loading="loading"
  60. :table="table"
  61. :data="tableData"
  62. :columns="columns"
  63. :page="pageInfo"
  64. :size="size"
  65. @row-click="handClick"
  66. @page-curr-change="handlePageChange"
  67. @page-size-change="handleSizeChange"
  68. @screen-reset="
  69. pageInfo.curr = 1;
  70. parmValue.page = 1;
  71. searchList();
  72. "
  73. @screen-submit="
  74. pageInfo.curr = 1;
  75. parmValue.page = 1;
  76. searchList();
  77. "
  78. >
  79. <template #table-header="{}">
  80. <div style="width: 100%; height: 30px; line-height: 30px">
  81. <i class="el-icon-s-unfold" style="height: 10px"></i>库存操作记录
  82. </div>
  83. </template>
  84. <template #type_status="{ scope }">
  85. <el-tag
  86. :size="tablebtnSize"
  87. :type="scope.row.type == '0' ? 'warning' : ''"
  88. v-text="
  89. (statusOptions.find((item) => item.id == scope.row.type) || {})
  90. .label || '--'
  91. "
  92. ></el-tag>
  93. </template>
  94. </ex-table>
  95. </div>
  96. <div v-else>
  97. <no-auth></no-auth>
  98. </div>
  99. </div>
  100. </template>
  101. <script>
  102. import mixinPage from "@/mixins/elPaginationHandle";
  103. import resToken from "@/mixins/resToken";
  104. import asyncRequest from "@/apis/service/stock/survey";
  105. import countTo from "vue-count-to";
  106. import { mapGetters } from "vuex";
  107. export default {
  108. name: "survey",
  109. mixins: [mixinPage, resToken],
  110. components: {
  111. countTo,
  112. },
  113. computed: {
  114. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  115. powers() {
  116. let tran =
  117. this.$store.getters.btnList.find(
  118. (item) => item.menu_route == "survey"
  119. ) || {};
  120. if (tran && tran.action && tran.action.length > 0) {
  121. return tran.action;
  122. } else {
  123. return [];
  124. }
  125. },
  126. },
  127. data() {
  128. return {
  129. statusOptions: [
  130. {
  131. id: "1",
  132. label: "增加",
  133. },
  134. {
  135. id: "2",
  136. label: "减少",
  137. },
  138. ],
  139. stock_code: "",
  140. supplier_code: "",
  141. parmValue: {
  142. supplierNo:[],
  143. supplier_code: [],
  144. stock_code: [],
  145. page: 1,
  146. size: 15,
  147. },
  148. stock_list: [
  149. {
  150. id: "1",
  151. icon: "el-icon-box",
  152. label: "当前库存",
  153. endVal: 0,
  154. },
  155. {
  156. id: "2",
  157. icon: "el-icon-download",
  158. label: "待入库",
  159. endVal: 0,
  160. },
  161. {
  162. id: "3",
  163. icon: "el-icon-upload2",
  164. label: "待出库",
  165. endVal: 0,
  166. },
  167. {
  168. id: "4",
  169. icon: "el-icon-shopping-cart-full",
  170. label: "可用库存",
  171. endVal: 0,
  172. },
  173. {
  174. id: "5",
  175. icon: "el-icon-truck",
  176. label: "在途库存",
  177. endVal: 0,
  178. },
  179. ],
  180. loading: true,
  181. showModel: false,
  182. isDetail: false,
  183. modelId: 0,
  184. tableData: [], // 表格 - 数据
  185. table: {
  186. // 表格 - 参数
  187. stripe: true,
  188. border: true,
  189. // _defaultHeader_: ["setcol"],
  190. },
  191. // 表格 - 分页
  192. pageInfo: {
  193. size: 15,
  194. curr: 1,
  195. total: 0,
  196. },
  197. columns: [
  198. {
  199. prop: "id",
  200. label: "业务编号",
  201. },
  202. {
  203. prop: "action_type",
  204. label: "库存来源",
  205. width: "120px",
  206. },
  207. {
  208. prop: "type",
  209. label: "变化类别",
  210. _slot_: "type_status",
  211. width: "70px",
  212. },
  213. {
  214. prop: "stock",
  215. label: "变动数量",
  216. "min-width": "90px",
  217. },
  218. {
  219. prop: "code",
  220. label: "仓库所在公司编号",
  221. width: "140px",
  222. },
  223. {
  224. prop: "name",
  225. label: "仓库所在公司名称",
  226. width: "150px",
  227. },
  228. {
  229. prop: "wsm_code",
  230. label: "仓库编号",
  231. width: "170px",
  232. },
  233. {
  234. prop: "wsm_name",
  235. label: "仓库名称",
  236. width: "100px",
  237. },
  238. {
  239. prop: "action_name",
  240. label: "操作人",
  241. width: "70px",
  242. },
  243. {
  244. prop: "reviewer",
  245. label: "操作人所在部门",
  246. width: "120px",
  247. },
  248. {
  249. prop: "addtime",
  250. label: "操作时间",
  251. width: "145px",
  252. sortable: true,
  253. },
  254. ],
  255. };
  256. },
  257. mounted() {
  258. this.stock_code = "";
  259. this.supplier_code = "";
  260. this.stockList();
  261. this.searchList();
  262. },
  263. methods: {
  264. // 选择供应商
  265. selectSupplier(e) {
  266. if (e && e.id) {
  267. this.parmValue.supplier_code = [e.code];
  268. this.supplier_code = e.code;
  269. } else {
  270. this.parmValue.stock_code = [];
  271. this.parmValue.supplier_code = [];
  272. this.stock_code = "";
  273. this.supplier_code = "";
  274. }
  275. this.parmValue.page = 1;
  276. this.pageInfo.curr = 1;
  277. this.stockList();
  278. this.searchList();
  279. },
  280. //供应商公司选择
  281. supplierChange(e) {
  282. if (e && e.id) {
  283. this.parmValue.supplierNo = [e.code]; //供应商编码
  284. } else {
  285. this.parmValue.supplierNo = [];
  286. }
  287. },
  288. // 选择供应商仓库
  289. selectStock(e) {
  290. if (e && e.id) {
  291. this.parmValue.stock_code = [e.code];
  292. this.stock_code = e.code;
  293. } else {
  294. this.parmValue.stock_code = [];
  295. this.stock_code = "";
  296. }
  297. this.parmValue.page = 1;
  298. this.pageInfo.curr = 1;
  299. this.stockList();
  300. this.searchList();
  301. },
  302. //获取表格上方的卡片数据
  303. async stockList() {
  304. let model = {
  305. supplier_code: this.supplier_code,
  306. stock_code: this.stock_code,
  307. };
  308. const res = await asyncRequest.getstockwsm(model);
  309. // console.log(res);
  310. if (res && res.code === 0 && res.data) {
  311. const {
  312. intra_stock,
  313. total_stock,
  314. usable_stock,
  315. wait_in_stock,
  316. wait_out_stock,
  317. // warn_stock,
  318. } = res.data;
  319. this.stock_list[0].endVal = Number(total_stock);
  320. this.stock_list[1].endVal = Number(wait_in_stock);
  321. this.stock_list[2].endVal = Number(wait_out_stock);
  322. this.stock_list[3].endVal = Number(usable_stock);
  323. this.stock_list[4].endVal = Number(intra_stock);
  324. } else if (res && res.code >= 100 && res.code <= 104) {
  325. await this.logout();
  326. } else {
  327. }
  328. },
  329. //获取表格数据
  330. async searchList() {
  331. this.tableData = [];
  332. this.loading = true;
  333. let model = JSON.parse(JSON.stringify(this.parmValue));
  334. model.supplier_code = this.supplier_code;
  335. model.stock_code = this.stock_code;
  336. const res = await asyncRequest.list(model);
  337. if (res && res.code === 0 && res.data) {
  338. this.tableData = res.data.list;
  339. this.tableData.forEach((v) => {
  340. if (v.empty) {
  341. v.code = v.empty.code;
  342. v.wsm_name = v.empty.wsm_name;
  343. v.name = v.empty.name;
  344. }
  345. });
  346. this.pageInfo.total = Number(res.data.count);
  347. } else if (res && res.code >= 100 && res.code <= 104) {
  348. await this.logout();
  349. } else {
  350. this.tableData = [];
  351. this.pageInfo.total = 0;
  352. }
  353. this.loading = false;
  354. },
  355. },
  356. };
  357. </script>
  358. <style lang="scss" scoped>
  359. .card {
  360. width: 200px;
  361. height: 115px;
  362. flex: 1;
  363. }
  364. @media screen and (max-width: 1500px) {
  365. .card {
  366. width: 160px;
  367. }
  368. }
  369. @media screen and (max-width: 1350px) {
  370. .card {
  371. width: 130px;
  372. }
  373. }
  374. .stock-survey {
  375. width: 100%;
  376. display: flex;
  377. // position: relative;
  378. justify-content: space-around;
  379. overflow: hidden;
  380. padding: 20px 0 20px 10px;
  381. text-align: center;
  382. .icon {
  383. font-size: 40px;
  384. padding-bottom: 10px;
  385. }
  386. p {
  387. cursor: default;
  388. }
  389. }
  390. </style>