index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <el-dialog
  3. :title="'仓库商品选择'"
  4. :center="true"
  5. align="left"
  6. top="8vh"
  7. width="1040px"
  8. @close="showModelThis = false"
  9. :close-on-click-modal="false"
  10. :visible.sync="showModelThis"
  11. v-loading="loading"
  12. element-loading-text="拼命加载中"
  13. element-loading-spinner="el-icon-loading"
  14. element-loading-background="rgba(0, 0, 0, 0.8)"
  15. append-to-body
  16. >
  17. <el-card style="margin-top: -20px" class="modal-form-style">
  18. <el-table
  19. :data="tableData"
  20. border
  21. :size="size"
  22. v-loading="loading"
  23. style="width: 100%"
  24. @selection-change="handleSelectionChange"
  25. >
  26. <template v-for="(column, index) in columns">
  27. <el-table-column
  28. v-if="column._slot_ && column._slot_ === 'good_name'"
  29. show-overflow-tooltip
  30. :key="column + index"
  31. >
  32. <template slot-scope="scope">
  33. <span>{{ scope.row.good_name }}</span>
  34. <span
  35. v-for="(si, sii) in scope.row.specinfo"
  36. :key="si.spec_value_id + sii"
  37. >{{ sii === 0 ? "_" : "-" }}{{ si.spec_name }}[{{
  38. si.spec_value
  39. }}]</span
  40. >
  41. </template>
  42. </el-table-column>
  43. <el-table-column
  44. v-else
  45. :key="column + index"
  46. show-overflow-tooltip
  47. v-bind="column"
  48. />
  49. </template>
  50. </el-table>
  51. <div
  52. v-if="pageInfo !== false && tableData && tableData.length > 0"
  53. class="Pagination clear"
  54. style="text-align: right; padding: 16px 0 0 0"
  55. >
  56. <div style="wiith: 90%" class="fl">
  57. <el-pagination
  58. :current-page="pageInfo.curr"
  59. :page-size="pageInfo.size"
  60. :size="searchSize"
  61. layout="total, prev, pager, next, jumper"
  62. :total="pageInfo.total"
  63. @size-change="
  64. (pageInfo.curr = 1),
  65. (parmValue.page = 1),
  66. (pageInfo.size = $event),
  67. (parmValue.size = $event),
  68. searchList()
  69. "
  70. @current-change="
  71. (pageInfo.curr = $event), (parmValue.page = $event), searchList()
  72. "
  73. />
  74. </div>
  75. <div class="fr">
  76. <el-button type="primary" :size="'mini'" @click="resultList()"
  77. >保 存</el-button
  78. >
  79. </div>
  80. </div>
  81. </el-card>
  82. </el-dialog>
  83. </template>
  84. <script>
  85. import asyncRequest from "@/apis/components/search-stock-good-modal";
  86. import resToken from "@/mixins/resToken";
  87. import mixinPage from "@/mixins/elPaginationHandle";
  88. import { mapGetters } from "vuex";
  89. import columns from "./columns";
  90. export default {
  91. name: "searchStockGoodModal",
  92. mixins: [resToken, mixinPage],
  93. computed: {
  94. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  95. },
  96. props: ["showModel", "once", "code", "good_code", "cat_id"],
  97. /**
  98. * 属性集合
  99. * @param {Boolean} showModel : 是否弹出弹窗 必填
  100. * @param {Boolean} once : 是否只选一条 非必填
  101. * @param {Boolean} code : 仓库CODE 非必填
  102. */
  103. /**
  104. * 事件集合
  105. * @searchChange : 选中值变化调用 抛出选中数据
  106. */
  107. data() {
  108. return {
  109. options: [],
  110. multipleSelection: [],
  111. selectLoading: false,
  112. loading: true,
  113. showModelThis: false,
  114. parmValue: {
  115. wsm_code: "", //仓库code
  116. cat_id: "",
  117. page: 1, // 页码
  118. size: 10, // 每页显示条数
  119. },
  120. tableData: [],
  121. passwordModel: false,
  122. passwordModelId: 0,
  123. isPasswordDetail: false,
  124. // 表格 - 数据
  125. tableData: [],
  126. // 表格 - 参数
  127. table: {
  128. stripe: true,
  129. border: true,
  130. // _defaultHeader_: ["setcol"],
  131. },
  132. // 表格 - 分页
  133. pageInfo: {
  134. size: 10,
  135. curr: 1,
  136. total: 0,
  137. },
  138. // 表格 - 列参数
  139. columns: columns,
  140. };
  141. },
  142. watch: {
  143. showModel: function (val) {
  144. this.showModelThis = val;
  145. if (val) {
  146. this.supplierCode = [];
  147. this.searchList();
  148. }
  149. },
  150. showModelThis(val) {
  151. if (!val) {
  152. this.$emit("cancel");
  153. }
  154. },
  155. },
  156. methods: {
  157. restSearch() {
  158. this.parmValue = {
  159. wsm_code: "", //仓库code
  160. cat_id: "",
  161. page: 1, // 页码
  162. size: 10, // 每页显示条数
  163. };
  164. // 表格 - 分页
  165. this.pageInfo = {
  166. size: 10,
  167. curr: 1,
  168. total: 0,
  169. };
  170. this.searchList();
  171. },
  172. async searchList() {
  173. this.loading = true;
  174. this.parmValue.wsm_code = this.code || "";
  175. this.parmValue.type_code = this.good_code || "";
  176. this.parmValue.stock_max = "1";
  177. this.parmValue.cat_id = this.cat_id;
  178. const res = await asyncRequest.list(this.parmValue);
  179. if (res && res.code === 0 && res.data) {
  180. this.tableData = res.data.list;
  181. this.tableData.forEach((v) => {
  182. v.class_cat = "";
  183. if (v.can && v.can.length > 0) {
  184. v.can.forEach((x, i) => {
  185. v.class_cat += i === 0 ? x.name : "_" + x.name;
  186. });
  187. }
  188. });
  189. this.pageInfo.total = Number(res.data.count);
  190. } else if (res && res.code >= 100 && res.code <= 104) {
  191. await this.logout();
  192. } else {
  193. this.tableData = [];
  194. this.pageInfo.total = 0;
  195. }
  196. this.loading = false;
  197. },
  198. async handleSelectionChange(selection) {
  199. this.multipleSelection = selection;
  200. },
  201. async resultList() {
  202. if (
  203. this.multipleSelection &&
  204. this.multipleSelection.length > 1 &&
  205. this.once
  206. ) {
  207. this.$message.warning("只能选择一条商品信息!");
  208. return;
  209. }
  210. let list = JSON.parse(JSON.stringify(this.multipleSelection));
  211. list.map((v) => {
  212. delete v["id"];
  213. return v;
  214. });
  215. this.showModelThis = false;
  216. this.$emit("searchChange", list);
  217. },
  218. },
  219. };
  220. </script>
  221. <style>
  222. </style>