backGoodShow.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <div class="project-backGoodShow" v-loading="loading">
  3. <div
  4. v-for="(item, index) in allList"
  5. :key="item.title + index"
  6. class="project-backGoodShow-main"
  7. >
  8. <div class="project-backGoodShow-title">商品要求{{ index + 1 }}</div>
  9. <div class="project-backGoodShow-ask-table">
  10. <template v-if="item.ladder">
  11. <el-table
  12. :data="item.ladder"
  13. :size="'mini'"
  14. border
  15. stripe
  16. style="width: 100%"
  17. >
  18. <el-table-column prop="good_type" label="商品类型" width="80px">
  19. <template slot-scope="scope">
  20. <el-tag
  21. :size="'mini'"
  22. v-text="
  23. (
  24. statusOptions.find(
  25. (item) => item.value == scope.row.good_type
  26. ) || {}
  27. ).label || '--'
  28. "
  29. ></el-tag
  30. ></template>
  31. </el-table-column>
  32. <el-table-column prop="budget_price" label="预算单价" width="110" />
  33. <el-table-column prop="num" label="购买数量" width="110" />
  34. <el-table-column prop="cat_name" label="商品分类" />
  35. <el-table-column prop="good_img" label="图片" width="50">
  36. <template slot-scope="scope">
  37. <div
  38. v-if="scope.row.good_img"
  39. style="width: 20px; height: 20px"
  40. class="hover"
  41. v-viewer
  42. >
  43. <img
  44. :src="scope.row.good_img"
  45. style="display: inline-block; width: 100%; height: 100%"
  46. alt=""
  47. />
  48. </div>
  49. </template>
  50. </el-table-column>
  51. <el-table-column prop="good_name" label="商品名称" />
  52. </el-table>
  53. </template>
  54. </div>
  55. <div class="project-backGoodShow-title">
  56. 商品反馈情况
  57. <el-tooltip
  58. effect="dark"
  59. class="fr"
  60. content="添加线上商品"
  61. style="margin: 16px 10px 0 0"
  62. placement="top"
  63. >
  64. <i class="el-icon-zoom-in tb-icon" @click="addId(index)"></i>
  65. </el-tooltip>
  66. </div>
  67. <div class="project-backGoodShow-backGood-table">
  68. <template v-if="item.tableData">
  69. <ex-table
  70. v-loading="item.loading"
  71. :table="table"
  72. :data="item.tableData"
  73. :columns="columns"
  74. :page="item.pageInfo"
  75. :size="'mini'"
  76. @page-curr-change="handlePageChange($event, index)"
  77. @page-size-change="handleSizeChange($event, index)"
  78. @screen-reset="
  79. item.pageInfo.curr = 1;
  80. item.page = 1;
  81. searchList(index);
  82. "
  83. @screen-submit="
  84. item.pageInfo.curr = 1;
  85. item.page = 1;
  86. searchList(index);
  87. "
  88. >
  89. <template #operation="{ scope }">
  90. <el-tooltip
  91. effect="dark"
  92. content="删除"
  93. placement="top"
  94. v-if="scope.row.data_source === '1' && status==='1'"
  95. >
  96. <i
  97. class="el-icon-delete tb-icon"
  98. @click="deleteId(scope.row.id, index)"
  99. ></i>
  100. </el-tooltip>
  101. </template>
  102. </ex-table>
  103. </template>
  104. </div>
  105. </div>
  106. <search-good-online-table-modal
  107. :showModel="showModel"
  108. :sitem="searchItem"
  109. @cancel="showModel = false"
  110. @submitRes="resetFormData"
  111. />
  112. </div>
  113. </template>
  114. <script>
  115. import asyncRequest from "@/apis/service/sellOut/project";
  116. import resToken from "@/mixins/resToken";
  117. import columnsForm from "./columnsForm";
  118. import searchGoodOnlineTableModal from "./search-good-online-table-modal";
  119. export default {
  120. name: "backGoodShow",
  121. props: ["showModel", "sitem", "id", "type"],
  122. mixins: [resToken],
  123. components: {
  124. searchGoodOnlineTableModal,
  125. },
  126. watch: {
  127. // showModel: function (val) {
  128. // this.showModelThis = val;
  129. // if (val) {
  130. // this.initForm();
  131. // }
  132. // },
  133. // showModelThis(val) {
  134. // if (!val) {
  135. // this.$emit("cancel");
  136. // }
  137. // },
  138. },
  139. data() {
  140. return {
  141. showModel: false,
  142. searchItem: {},
  143. loading: false,
  144. allList: [],
  145. status: "",
  146. projectNo: "",
  147. statusOptions: [
  148. { value: "1", label: "竞品" },
  149. { value: "2", label: "竞聘" },
  150. ],
  151. table: {
  152. stripe: true,
  153. border: true,
  154. // _defaultHeader_: ["setcol"],
  155. },
  156. // 表格 - 列参数
  157. columns: columnsForm,
  158. };
  159. },
  160. mounted() {
  161. this.initForm();
  162. },
  163. methods: {
  164. //初始化整个组件
  165. async initForm() {
  166. this.loading = true;
  167. await this.initListData();
  168. this.loading = false;
  169. console.log(this.allList);
  170. await this.allSearchList();
  171. },
  172. async resetFormData(index) {
  173. this.allList[index].pageInfo = {
  174. size: 15,
  175. curr: 1,
  176. total: 0,
  177. };
  178. this.allList[index].loading = true;
  179. this.allList[index].tableData = [];
  180. await this.searchList(index);
  181. },
  182. //初始化整个组件
  183. async initListData() {
  184. console.log(this.sitem);
  185. this.allList = [];
  186. const { projectNo, ladder, status } = this.sitem;
  187. this.status = status;
  188. this.projectNo = projectNo;
  189. if (ladder && ladder.length > 0) {
  190. ladder.forEach((e) => {
  191. let item = JSON.parse(JSON.stringify(e));
  192. console.log(item);
  193. let model = {
  194. ladder: [item],
  195. pageInfo: {
  196. size: 15,
  197. curr: 1,
  198. total: 0,
  199. },
  200. pgNo: item.pgNo,
  201. loading: false,
  202. tableData: [],
  203. };
  204. this.allList.push(model);
  205. });
  206. }
  207. },
  208. async allSearchList() {
  209. if (this.allList && this.allList.length > 0) {
  210. this.allList.forEach(async (e, i) => {
  211. await this.searchList(i);
  212. });
  213. }
  214. },
  215. //页数选择
  216. async handlePageChange(e, index) {
  217. this.allList[index].pageInfo.curr = e;
  218. await this.searchList(index);
  219. },
  220. //页面条数选择
  221. async handleSizeChange(e, index) {
  222. this.allList[index].pageInfo.curr = 1;
  223. this.allList[index].pageInfo.size = e;
  224. await this.searchList(index);
  225. },
  226. async searchList(index) {
  227. const { pageInfo, pgNo } = this.allList[index];
  228. const { size, curr } = pageInfo;
  229. this.allList[index].loading = true;
  230. let model = {
  231. page: curr,
  232. size: size,
  233. zxNo: "",
  234. infoNo: "",
  235. bidNo: "",
  236. pgNo: pgNo,
  237. projectNo: this.projectNo,
  238. };
  239. const { code, data } = await asyncRequest.back_good_list(model);
  240. if (code === 0) {
  241. const { list, count } = data;
  242. this.allList[index].tableData = list;
  243. // this.allList[index].tableData.map((v) => {
  244. // v.class_cat = "";
  245. // if (v.can && v.can.length > 0) {
  246. // v.can.forEach((x, i) => {
  247. // v.class_cat += i === 0 ? x.name : "/" + x.name;
  248. // });
  249. // }
  250. // return v;
  251. // });
  252. this.allList[index].pageInfo.total = Number(count);
  253. } else if (code >= 100 && code <= 104) {
  254. await this.logout();
  255. } else {
  256. this.allList[index].tableData = [];
  257. this.allList[index].pageInfo.total = 0;
  258. }
  259. this.allList[index].loading = false;
  260. },
  261. addId(index) {
  262. let ladder = JSON.parse(JSON.stringify(this.allList[index].ladder));
  263. this.searchItem = ladder[0];
  264. this.searchItem.platform_code = this.sitem.platform_code;
  265. this.searchItem.platform_id = this.sitem.platform_id;
  266. this.searchItem.platform_name = this.sitem.platform_name;
  267. this.searchItem.company = this.sitem.company;
  268. this.searchItem.companyNo = this.sitem.companyNo;
  269. this.searchItem.pgNo_index = index;
  270. this.showModel = true;
  271. },
  272. async deleteId(id, index) {
  273. await this.$confirm("确定要删除?", {
  274. confirmButtonText: "确定",
  275. cancelButtonText: "取消",
  276. type: "warning",
  277. })
  278. .then(async () => {
  279. const model = {
  280. id: [id],
  281. };
  282. const res = await asyncRequest.project_online_good_del(model);
  283. if (res && res.code === 0) {
  284. this.$notify.success({
  285. title: "删除成功",
  286. message: "",
  287. });
  288. this.searchList(index);
  289. } else if (res && res.code >= 100 && res.code <= 104) {
  290. await this.logout();
  291. } else {
  292. this.$message.warning(res.message);
  293. }
  294. })
  295. .catch(() => {
  296. console.log("取消");
  297. });
  298. },
  299. },
  300. };
  301. </script>
  302. <style lang="scss" scoped>
  303. .project-backGoodShow {
  304. box-sizing: border-box;
  305. width: 100%;
  306. .project-backGoodShow-main {
  307. padding: 2px 16px 16px 16px;
  308. // background: #fefefe;
  309. border-radius: 5px;
  310. overflow: hidden;
  311. border: 1px solid #f0f0f0;
  312. margin: 0 0 16px 0;
  313. .project-backGoodShow-title {
  314. height: 48px;
  315. line-height: 48px;
  316. color: #676767;
  317. }
  318. }
  319. }
  320. </style>