main.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. <ex-table
  19. v-loading="loading"
  20. :table="table"
  21. :data="tableData"
  22. :columns="columns"
  23. :page="pageInfo"
  24. :size="'mini'"
  25. @page-curr-change="handlePageChange"
  26. @page-size-change="handleSizeChange"
  27. @screen-reset="
  28. pageInfo.curr = 1;
  29. parmValue.page = 1;
  30. searchList();
  31. "
  32. @screen-submit="
  33. pageInfo.curr = 1;
  34. parmValue.page = 1;
  35. searchList();
  36. "
  37. >
  38. <template #table-header="{ selection }">
  39. <div style="width: 100%">
  40. <el-row style="margin-top: -15px">
  41. <el-col :span="24">
  42. <el-col :span="4" style="width: 210px">
  43. <search-brand
  44. :value="parmValue.brandid"
  45. :disabled="false"
  46. :size="'mini'"
  47. :isDetail="false"
  48. :names="''"
  49. :placeholder="'品牌'"
  50. @searchChange="brandidsearchChange"
  51. />
  52. </el-col>
  53. <el-col :span="6" style="width: 370px; padding: 0 0 0 10px">
  54. <good-class
  55. :value="parmValue.cat_id"
  56. @handleChange="goods_class_change"
  57. :disabled="false"
  58. :size="searchSize"
  59. :isDetail="false"
  60. :placeholder="'分类'"
  61. />
  62. </el-col>
  63. <el-col :span="3" class="fr" style="width: 66px">
  64. <el-button
  65. :size="'mini'"
  66. type="primary"
  67. style="float: right; margin-left: 5px"
  68. @click="searchList"
  69. >
  70. 刷新
  71. </el-button>
  72. </el-col>
  73. <el-col :span="4" class="fr" style="width: 66px">
  74. <el-button
  75. type="warning"
  76. class="fr"
  77. :size="'mini'"
  78. @click="restSearch"
  79. >
  80. 重置
  81. </el-button>
  82. </el-col>
  83. </el-col>
  84. <el-col :span="24" style="padding: 10px 0 0 0">
  85. <el-col :span="4" style="width: 450px">
  86. <el-input
  87. clearable
  88. :size="'mini'"
  89. v-model="sinput"
  90. :maxlength="40"
  91. placeholder="关键字"
  92. >
  93. <el-select
  94. v-model="select"
  95. style="width: 120px"
  96. slot="prepend"
  97. placeholder="关键字类型"
  98. >
  99. <el-option label="商品名称" value="1" />
  100. <el-option label="商品编码" value="2" />
  101. <el-option label="平台商品编码" value="3" /> </el-select
  102. ></el-input>
  103. </el-col>
  104. <el-col :span="3" style="width: 66px; float: right">
  105. <el-button
  106. :size="'mini'"
  107. type="success"
  108. style="float: right; margin-left: 5px"
  109. @click="resultList(selection)"
  110. >
  111. 保存
  112. </el-button>
  113. </el-col>
  114. </el-col>
  115. </el-row>
  116. </div>
  117. </template>
  118. <template #good_thumb_img="{ scope }">
  119. <div
  120. v-if="scope.row.good_thumb_img"
  121. style="width: 20px; height: 20px"
  122. class="hover"
  123. v-viewer
  124. >
  125. <img
  126. :src="scope.row.good_thumb_img"
  127. style="display: inline-block; width: 100%; height: 100%"
  128. alt=""
  129. />
  130. </div>
  131. </template>
  132. <template #model="{ scope }">
  133. <span v-for="(si, sii) in scope.row.specinfo" :key="si.spec_id">
  134. <span v-if="sii !== 0">--</span
  135. ><span>{{ si.spec_name }}[{{ si.spec_value }}]</span></span
  136. >
  137. </template>
  138. <template #is_stock="{ scope }">
  139. <span>{{ scope.row.is_stock === "1" ? "库存品" : "非库存品" }} </span>
  140. </template>
  141. </ex-table>
  142. </el-card>
  143. </el-dialog>
  144. </template>
  145. <script>
  146. import asyncRequest from "@/apis/components/search-good-online-modal";
  147. import resToken from "@/mixins/resToken";
  148. import mixinPage from "@/mixins/elPaginationHandle";
  149. import { mapGetters } from "vuex";
  150. import columns from "./columns";
  151. export default {
  152. name: "searchGoodOnlineModal",
  153. mixins: [resToken, mixinPage],
  154. computed: {
  155. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  156. },
  157. props: ["showModel", "once", "sitem", "active"],
  158. /**
  159. * 属性集合
  160. * @param {Boolean} showModel : 是否弹出弹窗 必填
  161. * @param {Boolean} once : 是否只选一条 非必填
  162. */
  163. /**
  164. * 事件集合
  165. * @searchChange : 选中值变化调用 抛出选中数据
  166. */
  167. data() {
  168. return {
  169. select: "1",
  170. sinput: "",
  171. is_stock: [
  172. { id: "0", name: "非库存品" },
  173. { id: "1", name: "库存品" },
  174. ],
  175. selectLoading: false,
  176. searchName: "",
  177. supplierCode: [],
  178. loading: true,
  179. showModelThis: false,
  180. parmValue: {
  181. platform_code: [],
  182. companyNo: "",
  183. is_stock: "",
  184. exam_status: "",
  185. cat_id: [], // 商品属性code
  186. brandid: [],
  187. good_code: "", // 商品编码
  188. good_name: "", // 商品名称
  189. plat_code: "",
  190. page: 1, // 页码
  191. size: 15, // 每页显示条数
  192. },
  193. tableData: [],
  194. passwordModel: false,
  195. passwordModelId: 0,
  196. isPasswordDetail: false,
  197. // 表格 - 数据
  198. tableData: [],
  199. // 表格 - 参数
  200. table: {
  201. stripe: true,
  202. border: true,
  203. // _defaultHeader_: ["setcol"],
  204. },
  205. // 表格 - 分页
  206. pageInfo: {
  207. size: 15,
  208. curr: 1,
  209. total: 0,
  210. },
  211. // 表格 - 列参数
  212. columns: columns,
  213. };
  214. },
  215. watch: {
  216. showModel: function (val) {
  217. this.showModelThis = val;
  218. if (val) {
  219. this.restSearch();
  220. }
  221. },
  222. showModelThis(val) {
  223. if (!val) {
  224. this.$emit("cancel");
  225. }
  226. },
  227. },
  228. methods: {
  229. restSearch() {
  230. console.log(this.active);
  231. console.log(this.sitem);
  232. const { platform_code, company_id, is_stock } = this.sitem;
  233. this.parmValue = {
  234. platform_code: this.active ? platform_code : [],
  235. companyNo: this.active ? company_id : "",
  236. is_stock: this.active ? is_stock : "",
  237. cat_id: [], // 商品属性code
  238. brandid: [],
  239. exam_status: this.active ? "6" : "",
  240. good_code: "", // 商品编码
  241. good_name: "", // 商品名称
  242. plat_code: "",
  243. page: 1, // 页码
  244. size: 15, // 每页显示条数
  245. };
  246. // 表格 - 分页
  247. this.pageInfo = {
  248. size: 15,
  249. curr: 1,
  250. total: 0,
  251. };
  252. this.searchList();
  253. },
  254. async goods_class_change(e) {
  255. this.parmValue.cat_id = e;
  256. this.pageInfo.curr = 1;
  257. this.parmValue.page = 1;
  258. await this.searchList();
  259. },
  260. async brandidsearchChange(e) {
  261. const { id } = e;
  262. this.parmValue.brandid = id ? [id] : [];
  263. this.pageInfo.curr = 1;
  264. this.parmValue.page = 1;
  265. await this.searchList();
  266. },
  267. async platform_codesearchChange(e) {
  268. const { id, code, label } = e;
  269. this.parmValue.platform_code = id ? [id] : [];
  270. this.pageInfo.curr = 1;
  271. this.parmValue.page = 1;
  272. await this.searchList();
  273. },
  274. async company_idsearchChange(e) {
  275. const { id, code, label } = e;
  276. this.parmValue.company_id = code || "";
  277. this.pageInfo.curr = 1;
  278. this.parmValue.page = 1;
  279. await this.searchList();
  280. },
  281. async searchList() {
  282. this.loading = true;
  283. let model = JSON.parse(JSON.stringify(this.parmValue));
  284. model.cat_id =
  285. model.cat_id.length > 0 ? model.cat_id[model.cat_id.length - 1] : "";
  286. model.brandid =
  287. model.brandid.length > 0 ? model.brandid[model.brandid.length - 1] : "";
  288. model.platform_code =
  289. model.platform_code.length > 0
  290. ? model.platform_code[model.platform_code.length - 1]
  291. : "";
  292. const res = await asyncRequest.list(model);
  293. if (res && res.code === 0 && res.data) {
  294. this.tableData = res.data.list;
  295. this.tableData.map((e) => {
  296. e.cat_name = "";
  297. if (e.cat_info && e.cat_info.length > 0) {
  298. e.cat_info.forEach((si, sii) => {
  299. e.cat_name += `${sii !== 0 ? "_" : ""}${si.name}`;
  300. });
  301. }
  302. return e;
  303. });
  304. this.pageInfo.total = Number(res.data.count);
  305. } else if (res && res.code >= 100 && res.code <= 104) {
  306. await this.logout();
  307. } else {
  308. this.tableData = [];
  309. this.pageInfo.total = 0;
  310. }
  311. this.loading = false;
  312. },
  313. async remoteMethod(query) {
  314. this.selectLoading = true;
  315. if (query !== "") {
  316. this.options = [];
  317. let formValue = {
  318. page: 1,
  319. size: 100,
  320. name: query,
  321. code: "",
  322. };
  323. let res = await asyncRequest.supplierList(formValue);
  324. if (res && res.code === 0 && res.data) {
  325. const { list } = res.data;
  326. this.options = list;
  327. } else if (res && res.code >= 100 && res.code <= 104) {
  328. await this.logout();
  329. } else {
  330. this.$message.warning(res.message);
  331. }
  332. } else {
  333. this.options = [];
  334. }
  335. this.selectLoading = false;
  336. },
  337. async resultList(selection) {
  338. if (selection && selection.length > 1 && this.once) {
  339. this.$message.warning("只能选择一条商品信息!");
  340. return;
  341. }
  342. this.showModelThis = false;
  343. this.$emit("resultList", selection);
  344. },
  345. },
  346. };
  347. </script>
  348. <style>
  349. </style>