changeBackGood.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <div class="choice-goods">
  3. <div class="top">
  4. <div v-if="allList[index]">
  5. <div class="project-backGoodShow" v-loading="allList[index].loading">
  6. <div class="project-backGoodShow-main">
  7. <div class="project-backGoodShow-title">
  8. 商品要求{{ index + 1 }}
  9. <el-button-group
  10. :size="'mini'"
  11. class="fr"
  12. style="margin: 8px 0 0 0"
  13. >
  14. <el-button
  15. class="fr"
  16. v-if="index !== 0"
  17. type="primary"
  18. :size="'mini'"
  19. icon="el-icon-arrow-left"
  20. @click="index--"
  21. >上一个</el-button
  22. >
  23. <el-button
  24. type="primary"
  25. class="fr"
  26. v-if="index + 1 !== allList.length"
  27. @click="next()"
  28. :size="'mini'"
  29. >下一个<i
  30. class="el-icon-arrow-right el-icon--right"
  31. :size="'mini'"
  32. ></i
  33. ></el-button>
  34. <el-button
  35. type="primary"
  36. class="fr"
  37. @click="next()"
  38. v-if="index + 1 === allList.length"
  39. :size="'mini'"
  40. >提交<i class="el-icon-upload el-icon--right"></i>
  41. </el-button>
  42. </el-button-group>
  43. </div>
  44. <div class="project-backGoodShow-ask-table">
  45. <template v-if="allList[index].ladder">
  46. <el-table
  47. :data="allList[index].ladder"
  48. :size="'mini'"
  49. border
  50. stripe
  51. style="width: 100%"
  52. >
  53. <el-table-column
  54. prop="good_type"
  55. label="商品类型"
  56. width="80px"
  57. >
  58. <template slot-scope="scope">
  59. <el-tag
  60. :size="'mini'"
  61. v-text="
  62. (
  63. statusOptions.find(
  64. (items) => items.value == scope.row.good_type
  65. ) || {}
  66. ).label || '--'
  67. "
  68. ></el-tag
  69. ></template>
  70. </el-table-column>
  71. <el-table-column
  72. prop="budget_price"
  73. label="预算单价"
  74. width="110"
  75. />
  76. <el-table-column prop="num" label="购买数量" width="110" />
  77. <el-table-column prop="cat_name" label="商品分类" />
  78. <el-table-column prop="good_img" label="图片" width="50">
  79. <template slot-scope="scope">
  80. <div
  81. v-if="scope.row.good_img"
  82. style="width: 20px; height: 20px"
  83. class="hover"
  84. v-viewer
  85. >
  86. <img
  87. :src="scope.row.good_img"
  88. style="
  89. display: inline-block;
  90. width: 100%;
  91. height: 100%;
  92. "
  93. alt=""
  94. />
  95. </div>
  96. </template>
  97. </el-table-column>
  98. <el-table-column prop="good_name" label="商品名称" />
  99. </el-table>
  100. </template>
  101. </div>
  102. <div class="project-backGoodShow-title">商品反馈情况</div>
  103. <div class="project-backGoodShow-backGood-table">
  104. <template v-if="allList[index].tableData">
  105. <!-- allList[index].pageInfo.curr = 1;
  106. searchList(index);
  107. -->
  108. <ex-table
  109. v-loading="allList[index].loading"
  110. :table="table"
  111. :data="allList[index].tableData"
  112. :columns="columns"
  113. :page="allList[index].pageInfo"
  114. :size="'mini'"
  115. @page-curr-change="handlePageChange($event, index)"
  116. @page-size-change="handleSizeChange($event, index)"
  117. @screen-reset="
  118. allList[index].pageInfo.curr = 1;
  119. searchList(index);
  120. "
  121. @screen-submit="
  122. allList[index].pageInfo.curr = 1;
  123. searchList(index);
  124. "
  125. @selection="selection_change"
  126. >
  127. <template #good_img="{ scope }">
  128. <div
  129. v-if="scope.row.good_img"
  130. style="width: 20px; height: 20px"
  131. class="hover"
  132. v-viewer
  133. >
  134. <img
  135. :src="scope.row.good_img"
  136. style="display: inline-block; width: 100%; height: 100%"
  137. alt=""
  138. />
  139. </div>
  140. </template>
  141. </ex-table>
  142. </template>
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. </div>
  148. <div class="bottom">
  149. <div class="table-main clear">
  150. <div class="table-main-index" style="padding-top: 40px">
  151. 已选中的商品
  152. </div>
  153. <div class="table-main-last">
  154. <el-table
  155. :data="tableData"
  156. border
  157. height="168px"
  158. :size="'mini'"
  159. style="width: 100%"
  160. >
  161. <el-table-column label="商品要求" property="noIndex" width="80">
  162. </el-table-column>
  163. <el-table-column property="date" label="商品名称" width="145" />
  164. <el-table-column property="name" label="图片" width="120">
  165. </el-table-column>
  166. <el-table-column
  167. prope="class_cat"
  168. label="分类"
  169. show-overflow-tooltip
  170. />
  171. <el-table-column
  172. prope="work_day"
  173. label="制作工期"
  174. show-overflow-tooltip
  175. />
  176. <el-table-column
  177. prope="delivery_day"
  178. label="物流时间"
  179. show-overflow-tooltip
  180. />
  181. <el-table-column fixed="right" label="操作" width="50">
  182. <template slot-scope="scope">
  183. <el-tooltip
  184. v-if="powers.some((item) => item == '006')"
  185. effect="dark"
  186. content="删除"
  187. placement="top"
  188. >
  189. <i
  190. class="el-icon-delete tb-icon"
  191. @click="deleteItem(scope.$index)"
  192. ></i>
  193. </el-tooltip>
  194. </template>
  195. </el-table-column>
  196. </el-table>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </template>
  202. <script>
  203. import asyncRequest from "@/apis/service/good-share";
  204. import resToken from "@/mixins/resToken";
  205. import columnsForm from "./columnsForm";
  206. export default {
  207. name: "changeBackGood",
  208. props: ["showModel", "sitem", "id", "type", "newTime"],
  209. mixins: [resToken],
  210. watch: {
  211. // showModel: function (val) {
  212. // this.showModelThis = val;
  213. // if (val) {
  214. // this.initForm();
  215. // }
  216. // },
  217. // showModelThis(val) {
  218. // if (!val) {
  219. // this.$emit("cancel");
  220. // }
  221. // },
  222. },
  223. data() {
  224. return {
  225. loading: false,
  226. allList: [],
  227. index: 0,
  228. projectNo: "",
  229. status: "",
  230. statusOptions: [
  231. { value: "1", label: "竞品" },
  232. { value: "2", label: "竞聘" },
  233. ],
  234. sitemStatusoptions: [
  235. { value: "1", label: "待商品反馈" },
  236. { value: "2", label: "待项目反馈商品选择" },
  237. { value: "3", label: "待项目方案制定" },
  238. { value: "4", label: "待方案选择" },
  239. { value: "5", label: "项目结束" },
  240. ],
  241. table: {
  242. stripe: true,
  243. border: true,
  244. // _defaultHeader_: ["setcol"],
  245. },
  246. // 表格 - 列参数
  247. columns: columnsForm,
  248. tableData: [],
  249. };
  250. },
  251. mounted() {
  252. this.initForm();
  253. },
  254. methods: {
  255. //初始化整个组件
  256. async initForm() {
  257. this.loading = true;
  258. this.tableData = [];
  259. await this.initListData();
  260. console.log(this.allList);
  261. this.loading = false;
  262. // console.log(this.allList);
  263. await this.searchList(this.index);
  264. },
  265. async next() {
  266. const { selection } = this.allList[this.index];
  267. if (selection.length === 0) {
  268. this.$message.warning("至少选择一个商品!");
  269. return;
  270. }
  271. if (this.index + 1 !== this.allList.length) {
  272. this.index++;
  273. await this.searchList(this.index);
  274. } else {
  275. await this.$confirm("确定要保存么?", "商品只能选择一次!", {
  276. confirmButtonText: "确定",
  277. cancelButtonText: "取消",
  278. type: "warning",
  279. })
  280. .then(async () => {
  281. await this.submitForm();
  282. })
  283. .catch(() => {
  284. console.log("取消");
  285. });
  286. }
  287. },
  288. deleteItem(index) {
  289. let list = JSON.parse(JSON.stringify(this.allList[this.index].selection));
  290. list.forEach((e, i) => {
  291. if (e.spuCode === this.tableData[index].spuCode) {
  292. this.allList[this.index].selection.splice(i, 1);
  293. }
  294. });
  295. this.tableData.splice(index, 1);
  296. },
  297. async submitForm() {
  298. if (!this.loading) {
  299. this.loading = true;
  300. let list = JSON.parse(JSON.stringify(this.tableData));
  301. const model = {
  302. feedid: [],
  303. };
  304. list.forEach((e) => {
  305. model.feedid.push(e.id);
  306. });
  307. let res = await asyncRequest.back_good_submit(model);
  308. this.loading = false;
  309. if (res && res.code === 0) {
  310. this.$notify.success({
  311. title: "保存成功!",
  312. message: "",
  313. });
  314. this.$emit("refresh");
  315. } else if (res && res.code >= 100 && res.code <= 104) {
  316. await this.logout();
  317. } else {
  318. this.$message.warning(res.message);
  319. }
  320. }
  321. },
  322. selection_change(e) {
  323. const { list } = e;
  324. this.allList[this.index].selection = JSON.parse(JSON.stringify(list));
  325. let change_all_list = [];
  326. this.allList.forEach((a, ai) => {
  327. const { selection } = a;
  328. if (selection && selection.length > 0) {
  329. selection.forEach((b) => {
  330. let item = JSON.parse(JSON.stringify(b));
  331. item.noIndex = ai + 1;
  332. change_all_list.push(item);
  333. });
  334. }
  335. });
  336. this.tableData = JSON.parse(JSON.stringify(change_all_list));
  337. },
  338. //初始化整个组件
  339. async initListData() {
  340. // console.log(this.sitem);
  341. this.allList = [];
  342. const { projectNo, ladder, status } = this.sitem;
  343. this.status = status;
  344. this.projectNo = projectNo;
  345. if (ladder && ladder.length > 0) {
  346. ladder.forEach((e) => {
  347. let item = JSON.parse(JSON.stringify(e));
  348. // console.log(item);
  349. let model = {
  350. ladder: [item],
  351. pageInfo: {
  352. size: 15,
  353. curr: 1,
  354. total: 0,
  355. },
  356. pgNo: item.pgNo,
  357. loading: true,
  358. selection: [],
  359. tableData: [],
  360. };
  361. this.allList.push(model);
  362. });
  363. }
  364. },
  365. async allSearchList() {
  366. if (this.allList && this.allList.length > 0) {
  367. this.allList.forEach(async (e, i) => {
  368. await this.searchList(i);
  369. });
  370. }
  371. },
  372. //页数选择
  373. async handlePageChange(e, index) {
  374. this.allList[index].pageInfo.curr = e;
  375. await this.searchList(index);
  376. },
  377. //页面条数选择
  378. async handleSizeChange(e, index) {
  379. this.allList[index].pageInfo.curr = 1;
  380. this.allList[index].pageInfo.size = e;
  381. await this.searchList(index);
  382. },
  383. async searchList(index) {
  384. const { pageInfo, pgNo } = this.allList[index];
  385. const { size, curr } = pageInfo;
  386. console.log(pgNo);
  387. this.allList[index].loading = true;
  388. let model = {
  389. page: curr,
  390. size: size,
  391. zxNo: "",
  392. infoNo: "",
  393. bidNo: "",
  394. pgNo: pgNo,
  395. status: this.status === "3" ? "1" : "",
  396. projectNo: this.projectNo,
  397. };
  398. const { code, data } = await asyncRequest.back_good_list(model);
  399. if (code === 0) {
  400. const { list, count } = data;
  401. this.allList[index].tableData = list;
  402. // list;
  403. this.allList[index].tableData.map((v) => {
  404. v.class_cat = "";
  405. if (v.can && v.can.length > 0) {
  406. v.can.forEach((x, i) => {
  407. v.class_cat += i === 0 ? x.name : "_" + x.name;
  408. });
  409. }
  410. return v;
  411. });
  412. this.allList[index].pageInfo.total = Number(count);
  413. } else if (code >= 100 && code <= 104) {
  414. await this.logout();
  415. } else {
  416. this.allList[index].tableData = [];
  417. this.allList[index].pageInfo.total = 0;
  418. }
  419. this.allList[index].loading = false;
  420. },
  421. },
  422. };
  423. </script>
  424. <style lang="scss" scoped>
  425. .choice-goods {
  426. position: relative;
  427. width: 100%;
  428. height: 100%;
  429. overflow: hidden;
  430. box-sizing: border-box;
  431. overflow: hidden;
  432. background: transparent;
  433. .top {
  434. position: absolute;
  435. top: 16px;
  436. left: 0;
  437. z-index: 1;
  438. background: #fff;
  439. width: 100%;
  440. min-height: calc(100% - 248px);
  441. height: calc(100% - 248px);
  442. box-sizing: border-box;
  443. padding: 0 16px 16px 16px;
  444. .project-backGoodShow {
  445. box-sizing: border-box;
  446. width: 100%;
  447. // padding: 2px 16px 16px 16px;
  448. .project-backGoodShow-main {
  449. // padding: 2px 16px 16px 16px;
  450. // background: #fefefe;
  451. // border-radius: 5px;
  452. // overflow: hidden;
  453. // border: 1px solid #f0f0f0;
  454. // margin: 0 0 16px 0;
  455. .project-backGoodShow-title {
  456. height: 48px;
  457. line-height: 48px;
  458. color: #676767;
  459. }
  460. }
  461. }
  462. }
  463. .bottom {
  464. position: absolute;
  465. bottom: 16px;
  466. right: 0;
  467. z-index: 1;
  468. background: #fff;
  469. width: 100%;
  470. min-height: calc(200px);
  471. height: calc(200px);
  472. box-sizing: border-box;
  473. // padding: 16px;
  474. .title {
  475. height: 50px;
  476. line-height: 50px;
  477. font-size: 18px;
  478. font-weight: bold;
  479. box-sizing: border-box;
  480. color: #565656;
  481. padding: 0 16px;
  482. border-right: 1px solid #f2f2f2;
  483. }
  484. .table-main {
  485. // padding: 16px;
  486. width: 100%;
  487. box-sizing: border-box;
  488. .table-main-index {
  489. float: left;
  490. width: 45px;
  491. padding: 16px;
  492. text-align: center;
  493. }
  494. .table-main-last {
  495. float: left;
  496. width: calc(100% - 45px);
  497. padding: 16px;
  498. border-left: 1px solid #f2f2f2;
  499. }
  500. }
  501. }
  502. }
  503. </style>