index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <div class="dataWeido pagePadding" style="padding: 0">
  3. <div v-if="powers.some((i) => i == '001')">
  4. <ex-table
  5. ref="table"
  6. v-loading="loading"
  7. :table="table"
  8. :data="tableData"
  9. :columns="columns"
  10. :page="pageInfo"
  11. :size="size"
  12. row-key="wsm_code"
  13. :expand-row-keys="expandKeys"
  14. @expand-change="handleExpandChange"
  15. @page-curr-change="handlePageChange"
  16. @page-size-change="handleSizeChange"
  17. @screen-reset="
  18. pageInfo.curr = 1;
  19. parmValue.page = 1;
  20. searchList();
  21. "
  22. @screen-submit="
  23. pageInfo.curr = 1;
  24. parmValue.page = 1;
  25. searchList();
  26. "
  27. >
  28. <template #table-header="{}">
  29. <div style="width: 100%">
  30. <el-row style="padding: 0 0 0 80px">
  31. <el-col :span="24">
  32. <el-col :span="12" style="width: 200px; padding-left: 10px">
  33. <search-stock
  34. :isDetail="true"
  35. :size="searchSize"
  36. :value="parmValue.stock_code"
  37. :disabled="parmValue.companyNo === ''"
  38. :placeholder="'出库仓库'"
  39. :isRelation="true"
  40. :companyNo="parmValue.companyNo"
  41. :names="''"
  42. @searchChange="selectStock"
  43. />
  44. </el-col>
  45. <!-- 搜索 -->
  46. <el-col :span="4" style="width: 54px">
  47. <el-button
  48. :size="searchSize"
  49. type="primary"
  50. class="fr"
  51. icon="el-icon-search"
  52. label=""
  53. @click="searchList"
  54. ></el-button>
  55. </el-col>
  56. <!-- 重置 -->
  57. <el-col :span="4" style="width: 54px; margin-left: 10px" class="mr5">
  58. <el-button
  59. :size="searchSize"
  60. class="fr"
  61. type="warning"
  62. @click="restSearch"
  63. >重置</el-button
  64. >
  65. </el-col>
  66. </el-col>
  67. </el-row>
  68. </div>
  69. </template>
  70. <template #expand="{ scope }">
  71. <el-table
  72. v-loading="scope.row.loading"
  73. :data="scope.row.child"
  74. style="width: 100%; paddind: 20px"
  75. border
  76. size="small"
  77. >
  78. <el-table-column
  79. label="商品编码"
  80. prop="spuCode"
  81. width="170"
  82. ></el-table-column>
  83. <el-table-column
  84. label="商品名称"
  85. prop="good_name"
  86. min-width="120"
  87. show-overflow-tooltip
  88. ></el-table-column>
  89. <el-table-column
  90. label="规格"
  91. prop="attribute"
  92. show-overflow-tooltip
  93. min-width="120"
  94. >
  95. <template slot-scope="scope">
  96. <span
  97. v-for="(si, sii) in scope.row.specinfo"
  98. :key="sii + si.spec_value_id"
  99. >{{ sii === 0 ? "" : "-" }}{{ si.spec_name }}[{{
  100. si.spec_value_name
  101. }}]</span
  102. >
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="分类" min-width="120" show-overflow-tooltip>
  106. <template slot-scope="scope">
  107. <span v-for="(si, sii) in scope.row.can" :key="sii + si.spec_value_id"
  108. >{{ sii === 0 ? "" : "_" }}{{ si.name }}</span
  109. >
  110. </template></el-table-column
  111. >
  112. <el-table-column
  113. label="品牌"
  114. prop="brand_name"
  115. show-overflow-tooltip
  116. width="100"
  117. ></el-table-column>
  118. <el-table-column
  119. label="单位"
  120. prop="unit"
  121. show-overflow-tooltip
  122. width="80"
  123. ></el-table-column>
  124. <el-table-column
  125. label="当前库存"
  126. show-overflow-tooltip
  127. prop="total_stock"
  128. width="80"
  129. ></el-table-column>
  130. <el-table-column
  131. label="待入库存"
  132. show-overflow-tooltip
  133. prop="wait_in_stock"
  134. width="80"
  135. ></el-table-column>
  136. <el-table-column
  137. label="待出库存"
  138. show-overflow-tooltip
  139. prop="wait_out_stock"
  140. width="80"
  141. ></el-table-column>
  142. <el-table-column
  143. label="可用库存"
  144. show-overflow-tooltip
  145. prop="usable_stock"
  146. width="80"
  147. ></el-table-column>
  148. <el-table-column
  149. label="在途库存"
  150. show-overflow-tooltip
  151. prop="intra_stock"
  152. width="80"
  153. ></el-table-column>
  154. </el-table>
  155. </template>
  156. </ex-table>
  157. <add-edit
  158. :id="modelId"
  159. :sitem="sitem"
  160. :show-model="showModel"
  161. :is-detail="isDetail"
  162. @refresh="searchList"
  163. @cancel="showModel = false"
  164. />
  165. </div>
  166. <div v-else>
  167. <no-auth></no-auth>
  168. </div>
  169. </div>
  170. </template>
  171. <script>
  172. import mixinPage from "@/mixins/elPaginationHandle";
  173. import resToken from "@/mixins/resToken";
  174. import asyncRequest from "@/apis/service/stock/dataWeido";
  175. import companyHelper from "@/mixins/companyHelper";
  176. import columns from "./columns";
  177. import { mapGetters } from "vuex";
  178. export default {
  179. name: "dataWeido",
  180. mixins: [mixinPage, resToken, companyHelper],
  181. computed: {
  182. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  183. powers() {
  184. const tran =
  185. this.$store.getters.btnList.find((item) => item.menu_route == "stockCount") || {};
  186. const { action } = tran ?? {};
  187. return action ?? [];
  188. },
  189. },
  190. data() {
  191. return {
  192. loading: false,
  193. loadingRows: {},
  194. stock_code: "",
  195. supplier_code: "",
  196. parmValue: {
  197. companyNo: "",
  198. supplier_code: [],
  199. stock_code: [],
  200. page: 1, // 页码
  201. size: 15, // 每页显示条数
  202. },
  203. expandKeys: [],
  204. // 表格 - 数据
  205. tableData: [],
  206. // 表格 - 参数
  207. table: {
  208. stripe: true,
  209. border: true,
  210. _defaultHeader_: ["setcol"],
  211. },
  212. // 表格 - 分页
  213. pageInfo: {
  214. size: 15,
  215. curr: 1,
  216. total: 0,
  217. },
  218. // 表格 - 列参数
  219. columns: columns,
  220. };
  221. },
  222. mounted() {
  223. this.onCompanyChange()
  224. this.searchList();
  225. },
  226. methods: {
  227. onCompanyChange(){
  228. console.log(this.currentCompany)
  229. this.parmValue.companyNo = this.currentCompany
  230. },
  231. //业务公司选择
  232. async supplierChange(e) {
  233. const { code } = e;
  234. this.parmValue.companyNo = code || ""; //业务公司编码
  235. this.parmValue.supplier_code = [];
  236. this.supplier_code = "";
  237. this.parmValue.stock_code = [];
  238. this.stock_code = "";
  239. this.parmValue.page = 1;
  240. this.pageInfo.curr = 1;
  241. await this.searchList();
  242. },
  243. // 选择供应商仓库
  244. async selectStock(e) {
  245. const { code } = e;
  246. this.parmValue.stock_code = code ? [code] : [];
  247. this.stock_code = code || "";
  248. // this.parmValue.stock_code = [];
  249. // this.stock_code = "";
  250. this.parmValue.page = 1;
  251. this.pageInfo.curr = 1;
  252. await this.searchList();
  253. },
  254. // 选择供应商
  255. async selectSupplier(e) {
  256. const { code } = e;
  257. this.parmValue.supplier_code = code ? [code] : [];
  258. this.supplier_code = code || "";
  259. this.parmValue.stock_code = [];
  260. this.stock_code = "";
  261. this.parmValue.page = 1;
  262. this.pageInfo.curr = 1;
  263. await this.searchList();
  264. },
  265. restSearch() {
  266. // 表格 - 分页
  267. this.pageInfo = {
  268. size: 15,
  269. curr: 1,
  270. total: 0,
  271. };
  272. this.parmValue = {
  273. companyNo: "",
  274. supplier_code: [],
  275. stock_code: [], //仓库编码
  276. page: 1, // 页码
  277. size: 15, // 每页显示条数
  278. };
  279. this.searchList();
  280. },
  281. async handleExpandChange(row) {
  282. if (!row.expand) {
  283. row.loading = true;
  284. const { data } = await asyncRequest.listChild({ wsm_code: row.wsm_code });
  285. row.loading = false;
  286. this.expandKeys.push(row.expand);
  287. row.child = data;
  288. row.expand = true;
  289. }
  290. },
  291. async searchList() {
  292. this.loading = true;
  293. let model = JSON.parse(JSON.stringify(this.parmValue));
  294. model.supplierNo = model.supplier_code.toString() || "";
  295. model.wsm_code = model.stock_code.toString() || "";
  296. delete model["supplier_code"];
  297. delete model["stock_code"];
  298. const res = await asyncRequest.list({
  299. ...model,
  300. needRela: true,
  301. });
  302. if (res && res.code === 0 && res.data) {
  303. const _list = res.data.list;
  304. this.tableData = _list.map((item) => ({
  305. ...item,
  306. child: [],
  307. expand: false,
  308. loading: false,
  309. }));
  310. this.pageInfo.total = Number(res.data.count);
  311. } else if (res && res.code >= 100 && res.code <= 104) {
  312. await this.logout();
  313. } else {
  314. this.tableData = [];
  315. this.pageInfo.total = 0;
  316. }
  317. this.loading = false;
  318. },
  319. },
  320. };
  321. </script>