index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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: 220px">
  43. <el-input
  44. :size="'mini'"
  45. v-model="parmValue.buy_num"
  46. :maxlength="40"
  47. disabled
  48. placeholder="起订量"
  49. ><template slot="prepend">起订量:</template></el-input
  50. >
  51. </el-col>
  52. <el-col :span="4" style="width: 460px; padding: 0 0 0 10px">
  53. <el-input
  54. :size="'mini'"
  55. v-model="company"
  56. :maxlength="40"
  57. clearable
  58. disabled
  59. placeholder="业务公司"
  60. />
  61. </el-col>
  62. <el-col :span="3" class="fr" style="width: 66px">
  63. <el-button
  64. :size="'mini'"
  65. type="primary"
  66. style="float: right; margin-left: 5px"
  67. @click="searchList"
  68. >
  69. 刷新
  70. </el-button>
  71. </el-col>
  72. <el-col :span="4" class="fr" style="width: 66px">
  73. <el-button
  74. type="warning"
  75. class="fr"
  76. :size="'mini'"
  77. @click="restSearch"
  78. >
  79. 重置
  80. </el-button>
  81. </el-col>
  82. </el-col>
  83. <el-col :span="24" style="padding: 10px 0 0 0">
  84. <el-col :span="4" style="width: 220px">
  85. <el-input
  86. :size="'mini'"
  87. v-model="parmValue.price"
  88. :maxlength="40"
  89. disabled
  90. placeholder="预算单价"
  91. ><template slot="prepend">售 价 ≤</template></el-input
  92. >
  93. </el-col>
  94. <el-col :span="4" style="width: 250px; padding: 0 0 0 10px">
  95. <el-input
  96. :size="'mini'"
  97. v-model="platform_name"
  98. :maxlength="40"
  99. clearable
  100. disabled
  101. placeholder="所属平台"
  102. />
  103. </el-col>
  104. <el-col :span="4" style="width: 280px; padding: 0 0 0 10px">
  105. <good-class
  106. :value="parmValue.cat_id"
  107. @handleChange="goods_class_change"
  108. :disabled="false"
  109. :size="'mini'"
  110. :isDetail="sitem.can_id !== ''"
  111. :placeholder="'分类'"
  112. />
  113. </el-col>
  114. <el-col :span="3" style="width: 66px; float: right">
  115. <el-button
  116. :size="'mini'"
  117. type="success"
  118. style="float: right; margin-left: 5px"
  119. @click="resultList(selection)"
  120. >
  121. 保存
  122. </el-button>
  123. </el-col>
  124. </el-col>
  125. </el-row>
  126. </div>
  127. </template>
  128. </ex-table>
  129. </el-card>
  130. </el-dialog>
  131. </template>
  132. <script>
  133. import asyncRequest from "@/apis/service/sellOut/project";
  134. import resToken from "@/mixins/resToken";
  135. import mixinPage from "@/mixins/elPaginationHandle";
  136. import { mapGetters } from "vuex";
  137. import columns from "./columns";
  138. export default {
  139. name: "searchGoodOnlineTableModal",
  140. mixins: [resToken, mixinPage],
  141. computed: {
  142. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  143. },
  144. props: ["showModel", "sitem"],
  145. /**
  146. * 属性集合
  147. * @param {Boolean} showModel : 是否弹出弹窗 必填
  148. * @param {Boolean} once : 是否只选一条 非必填
  149. */
  150. /**
  151. * 事件集合
  152. * @searchChange : 选中值变化调用 抛出选中数据
  153. */
  154. data() {
  155. return {
  156. options: [
  157. { id: "0", name: "非库存品" },
  158. { id: "1", name: "库存品" },
  159. ],
  160. company: "",
  161. platform_name: "",
  162. selectLoading: false,
  163. searchName: "",
  164. loading: true,
  165. showModelThis: false,
  166. parmValue: {
  167. buy_num: "", // 商品购买数量
  168. price: "", // 单价
  169. cat_id: "", // 分类id
  170. companyNo: "", // 业务公司id
  171. platform_code: "", //平台编号id
  172. page: 1, // 页码
  173. size: 15, // 每页显示条数
  174. },
  175. tableData: [],
  176. passwordModel: false,
  177. passwordModelId: 0,
  178. isPasswordDetail: false,
  179. // 表格 - 数据
  180. tableData: [],
  181. // 表格 - 参数
  182. table: {
  183. stripe: true,
  184. border: true,
  185. // _defaultHeader_: ["setcol"],
  186. },
  187. // 表格 - 分页
  188. pageInfo: {
  189. size: 15,
  190. curr: 1,
  191. total: 0,
  192. },
  193. // 表格 - 列参数
  194. columns: columns,
  195. };
  196. },
  197. watch: {
  198. showModel: function (val) {
  199. this.showModelThis = val;
  200. if (val) {
  201. this.restSearch();
  202. }
  203. },
  204. showModelThis(val) {
  205. if (!val) {
  206. this.$emit("cancel");
  207. }
  208. },
  209. },
  210. methods: {
  211. restSearch() {
  212. console.log(this.sitem);
  213. const {
  214. platform_id,
  215. companyNo,
  216. num,
  217. cat_id,
  218. budget_price,
  219. company,
  220. platform_name,
  221. } = this.sitem;
  222. console.log(this.sitem);
  223. this.company = company;
  224. this.platform_name = platform_name;
  225. this.parmValue = {
  226. buy_num: num, // 商品购买数量
  227. price: budget_price, // 单价
  228. cat_id: "", // 分类id
  229. companyNo: companyNo, // 业务公司id
  230. platform_code: platform_id, //平台编号id
  231. page: 1, // 页码
  232. size: 15, // 每页显示条数
  233. };
  234. // 表格 - 分页
  235. this.pageInfo = {
  236. size: 15,
  237. curr: 1,
  238. total: 0,
  239. };
  240. this.searchList();
  241. },
  242. async searchList() {
  243. this.loading = true;
  244. const res = await asyncRequest.get_good_online_list(this.parmValue);
  245. if (res && res.code === 0 && res.data) {
  246. this.tableData = res.data.list;
  247. // this.tableData.map((v) => {
  248. // // v.sale_price = this.setNum(v.sale_price);
  249. // // v.sale_fee = this.setNum(v.sale_fee);
  250. // // // v.num =
  251. // // //pa (v.sale_price);
  252. // return v;
  253. // });
  254. //
  255. this.pageInfo.total = Number(res.data.count);
  256. } else if (res && res.code >= 100 && res.code <= 104) {
  257. await this.logout();
  258. } else {
  259. this.tableData = [];
  260. this.pageInfo.total = 0;
  261. }
  262. this.loading = false;
  263. },
  264. async remoteMethod(query) {
  265. this.selectLoading = true;
  266. if (query !== "") {
  267. this.options = [];
  268. let formValue = {
  269. page: 1,
  270. size: 100,
  271. name: query,
  272. code: "",
  273. };
  274. let res = await asyncRequest.supplierList(formValue);
  275. if (res && res.code === 0 && res.data) {
  276. const { list } = res.data;
  277. this.options = list;
  278. } else if (res && res.code >= 100 && res.code <= 104) {
  279. await this.logout();
  280. } else {
  281. this.$message.warning(res.message);
  282. }
  283. } else {
  284. this.options = [];
  285. }
  286. this.selectLoading = false;
  287. },
  288. async resultList(selection) {
  289. if (selection && selection.length > 1 && this.once) {
  290. this.$message.warning("只能选择一条商品信息!");
  291. return;
  292. }
  293. this.loading = true;
  294. let model = {
  295. pgNo: this.sitem.pgNo,
  296. spuCode: [],
  297. source: "1",
  298. };
  299. selection.forEach((a) => {
  300. model.spuCode.push(a.skuCode);
  301. });
  302. let { code, data, message } = await asyncRequest.project_online_good_add(
  303. model
  304. );
  305. this.loading = false;
  306. if (code === 0) {
  307. this.$notify.success({
  308. title: "添加成功!",
  309. message: "",
  310. });
  311. this.showModelThis = false;
  312. this.$emit("submitRes", this.sitem.pgNo_index);
  313. } else if (code >= 100 && code <= 104) {
  314. await this.logout();
  315. } else {
  316. this.$message.warning(message);
  317. }
  318. },
  319. },
  320. };
  321. </script>
  322. <style>
  323. </style>