index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <div id="commodityManageMent">
  3. <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. :topType="topType"
  10. />
  11. <table-list
  12. :tableSets="tableSet"
  13. :tableData="tableData"
  14. :navText="navText"
  15. @addClick="addClick"
  16. :loading="loading"
  17. @editInfo="editInfo"
  18. >
  19. <template slot="btn" slot-scope="props">
  20. <el-button type="text" @click="addClick(props.scope.row, 0)"
  21. >修改</el-button
  22. >
  23. <el-button type="text" @click="changeStatus(props.scope.row)">{{
  24. props.scope.row.goodsStatus === 1 ? "下架" : "上架"
  25. }}</el-button>
  26. <el-button type="text" @click="del(props.scope.row)">删除</el-button>
  27. </template>
  28. </table-list>
  29. <pagination
  30. :total="total"
  31. :pageSize="formData.pageSize"
  32. :currentPage="formData.pageNum"
  33. @handleSizeChange="handleSizeChange"
  34. @handleCurrentChange="handleCurrentChange"
  35. />
  36. </div>
  37. </template>
  38. <script>
  39. import searchBoxNew from "@/components/searchBoxNew";
  40. import tableList from "@/components/tableList";
  41. import pagination from "@/components/pagination";
  42. export default {
  43. name: "CommodityManageMent",
  44. components: { searchBoxNew, tableList, pagination },
  45. data() {
  46. return {
  47. loading: false, //当前表单加载是否加载动画
  48. navText: {
  49. title: "商品列表",
  50. index: 0,
  51. ch: "条",
  52. num: false,
  53. border: true,
  54. choice: true,
  55. addHide: false,
  56. backFatherBtn: {
  57. status: false,
  58. title: "未定义",
  59. },
  60. },
  61. topType: true,
  62. //搜索
  63. formList: [
  64. {
  65. prop: "educationTypeId",
  66. placeholder: "教育类型",
  67. scope: "educationType",
  68. },
  69. {
  70. prop: "businessId",
  71. placeholder: "业务层次",
  72. scope: "businessLevel",
  73. edu: "educationTypeId",
  74. },
  75. {
  76. prop: "schoolId",
  77. placeholder: "院校",
  78. scope: "schoolList",
  79. edu: "educationTypeId",
  80. },
  81. {
  82. prop: "majorId",
  83. placeholder: "专业",
  84. scope: "Professional",
  85. edu: "educationTypeId",
  86. },
  87. {
  88. prop: "status",
  89. placeholder: "商品状态",
  90. scope: "select",
  91. noClear:false,
  92. options: [
  93. {
  94. label: "全部状态",
  95. value: "0,1",
  96. },
  97. {
  98. label: "有效",
  99. value: 1,
  100. },
  101. {
  102. label: "无效",
  103. value: 0,
  104. },
  105. ],
  106. },
  107. {
  108. prop: "goodsStatus",
  109. placeholder: "前台可售状态",
  110. scope: "select",
  111. options: [
  112. {
  113. label: "已上架",
  114. value: 1,
  115. },
  116. {
  117. label: "未上架",
  118. value: 0,
  119. },
  120. ],
  121. },
  122. {
  123. prop1: "validityStartTime",
  124. prop2: "validityEndTime",
  125. placeholder1: "商品有效期开始时间",
  126. placeholder2: "商品有效期结束时间",
  127. scope: "moreDataPicker",
  128. },
  129. // {
  130. // prop: "orderGoodsStatus",
  131. // placeholder: "退款状态",
  132. // scope: "select",
  133. // options: [
  134. // {
  135. // label: "已退款",
  136. // value: 1,
  137. // },
  138. // {
  139. // label: "退款中",
  140. // value: 2,
  141. // },
  142. // {
  143. // label: "拒绝退款",
  144. // value: 3,
  145. // },
  146. // ],
  147. // },
  148. {
  149. prop: "goodsName",
  150. placeholder: "请输入商品名称",
  151. },
  152. ],
  153. formData: {
  154. goodsType: "",
  155. status: "0,1",
  156. pageSize: 10,
  157. pageNum: 1,
  158. },
  159. // 表单
  160. tableSet: [
  161. {
  162. label: "商品名称",
  163. prop: "goodsName",
  164. scope: "editInfo",
  165. hidden: true,
  166. },
  167. {
  168. label: "商品编码",
  169. prop: "code",
  170. hidden: true,
  171. },
  172. {
  173. label: "专业",
  174. prop: "categoryName",
  175. hidden: true,
  176. },
  177. {
  178. label: "院校",
  179. prop: "schoolName",
  180. hidden: true,
  181. },
  182. {
  183. label: "业务层次",
  184. prop1: "projectName",
  185. prop2: "businessName",
  186. hidden: true,
  187. scope: "InfoMore",
  188. },
  189. {
  190. label: "教育类型",
  191. prop: "educationName",
  192. hidden: true,
  193. },
  194. {
  195. label: "学时",
  196. prop: "classHours",
  197. hidden: true,
  198. },
  199. {
  200. label: "商品内容视图",
  201. hidden: true,
  202. scope: "treeWatch",
  203. },
  204. {
  205. label: "商品价格",
  206. prop: "standPrice",
  207. hidden: true,
  208. scope: "leftCh",
  209. ch: "¥",
  210. },
  211. {
  212. label: "商品状态",
  213. prop: "status",
  214. hidden: true,
  215. scope: "hasTime",
  216. },
  217. {
  218. label: "商品有效期",
  219. prop1: "validityStartTime",
  220. prop2: "validityEndTime",
  221. scope: "TimeLists",
  222. Diszing: false,
  223. hidden: true,
  224. },
  225. {
  226. label: "学习服务期",
  227. prop1: "studyStartTime",
  228. prop2: "studyEndTime",
  229. scope: "TimeLists",
  230. Diszing: false,
  231. hidden: true,
  232. },
  233. {
  234. label: "供应方(服务)",
  235. prop: "supplyName",
  236. hidden: true,
  237. },
  238. {
  239. label: "最后编辑时间",
  240. prop: "updateTime",
  241. hidden: true,
  242. scope: "aTimeList",
  243. },
  244. {
  245. label: "创建时间",
  246. prop: "createTime",
  247. hidden: true,
  248. scope: "aTimeList",
  249. },
  250. {
  251. label: "可售状态",
  252. prop: "goodsStatus",
  253. hidden: true,
  254. scope: "status",
  255. },
  256. ],
  257. tableData: [], //表单数据
  258. total: 0, //一共多少条
  259. };
  260. },
  261. mounted() {
  262. this.search();
  263. },
  264. activated() {
  265. this.search();
  266. },
  267. methods: {
  268. editInfo(v) {
  269. this.addClick(v, 0);
  270. },
  271. search(int) {
  272. this.loading = true;
  273. if (int === 1) {
  274. this.formData.pageNum = 1;
  275. }
  276. if (int === 2) {
  277. this.formData = {
  278. goodsType: "",
  279. status: "0,1",
  280. pageSize: 10,
  281. pageNum: 1,
  282. };
  283. }
  284. if (int === 3) {
  285. this.formData.pageNum = 1;
  286. }
  287. var data = JSON.parse(JSON.stringify(this.formData));
  288. if (this.formData.validityStartTime) {
  289. data.validityStartTime = data.validityStartTime / 1000;
  290. }
  291. if (this.formData.validityEndTime) {
  292. data.validityEndTime = data.validityEndTime / 1000;
  293. }
  294. this.$api
  295. .inquireGoods(data)
  296. .then((res) => {
  297. this.tableData = res.rows;
  298. this.total = res.total;
  299. this.navText.index = res.total;
  300. })
  301. .finally(() => {
  302. this.loading = false;
  303. });
  304. },
  305. init() {
  306. this.search(2);
  307. },
  308. del(v) {
  309. this.$api.gradecheckGoodsChange({ goodsId: v.goodsId }).then((res) => {
  310. if (res.data > 0) {
  311. this.$message.error("已有学员正在学习该商品,无法删除");
  312. return;
  313. } else {
  314. this.$alert(
  315. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  316. "提示",
  317. {
  318. dangerouslyUseHTMLString: true,
  319. }
  320. )
  321. .then(() => {
  322. var data = {
  323. goodsId: v.goodsId,
  324. status: -1,
  325. };
  326. this.$api.editGoods(data).then((res) => {
  327. this.$message.success("删除成功");
  328. this.search();
  329. });
  330. })
  331. .catch(() => {
  332. this.$message({
  333. type: "info",
  334. message: "已取消删除",
  335. });
  336. });
  337. }
  338. });
  339. },
  340. addClick(v, int) {
  341. if (v === undefined) {
  342. this.$router.push({
  343. path: "commodityManageMentAdd",
  344. });
  345. } else {
  346. const jump = () => {
  347. this.$router.push({
  348. path: "commodityManageMentEdit",
  349. query: {
  350. id: v.goodsId,
  351. },
  352. });
  353. };
  354. const statusPage = this.$store.state.tagsView.visitedViews.some(
  355. (item) => {
  356. return item.name == "CommodityManageMentEdit";
  357. }
  358. );
  359. if (statusPage) {
  360. this.$store
  361. .dispatch("tagsView/delCachedView", {
  362. name: "CommodityManageMentEdit",
  363. })
  364. .then((res) => {
  365. jump();
  366. });
  367. } else {
  368. jump();
  369. }
  370. }
  371. },
  372. handleSizeChange(v) {
  373. this.formData.pageSize = v;
  374. this.formData.pageNum = 1;
  375. this.search();
  376. },
  377. handleCurrentChange(v) {
  378. this.formData.pageNum = v;
  379. this.search();
  380. },
  381. changeStatus(item) {
  382. var items = JSON.parse(JSON.stringify(item));
  383. items.goodsStatus = items.goodsStatus === 1 ? 0 : 1;
  384. this.$api.editGoods(items).then((res) => {
  385. if (item.goodsStatus === 1) {
  386. this.$message.success("下架成功");
  387. } else {
  388. this.$message.success("上架成功");
  389. }
  390. this.search();
  391. });
  392. },
  393. },
  394. };
  395. </script>
  396. <style lang="less" scoped>
  397. /deep/.el-button {
  398. border-radius: 8px;
  399. }
  400. /deep/.el-dialog {
  401. border-radius: 8px;
  402. .el-dialog__header {
  403. padding: 0;
  404. .hearders {
  405. height: 40px;
  406. display: flex;
  407. align-items: center;
  408. justify-content: space-between;
  409. padding: 0px 18px 0px 20px;
  410. border-bottom: 1px solid #e2e2e2;
  411. .leftTitle {
  412. font-size: 14px;
  413. font-weight: bold;
  414. color: #2f4378;
  415. }
  416. .rightBoxs {
  417. display: flex;
  418. align-items: center;
  419. img {
  420. width: 14px;
  421. height: 14px;
  422. margin-left: 13px;
  423. cursor: pointer;
  424. }
  425. }
  426. }
  427. }
  428. .el-dialog__footer {
  429. padding: 0;
  430. .dialog-footer {
  431. padding: 0px 40px;
  432. height: 70px;
  433. border-top: 1px solid #e2e2e2;
  434. display: flex;
  435. align-items: center;
  436. justify-content: flex-end;
  437. }
  438. }
  439. }
  440. .imgBox {
  441. width: 100%;
  442. // height: 210px;
  443. border: 1px solid #e2e2e2;
  444. border-radius: 8px;
  445. padding: 8px 8px 3px;
  446. display: flex;
  447. flex-direction: column;
  448. align-items: center;
  449. .imgLabel {
  450. flex: 1;
  451. width: 100%;
  452. border: 1px dotted #e2e2e2;
  453. color: #999;
  454. font-size: 14px;
  455. cursor: pointer;
  456. border-radius: 8px;
  457. .msPhoto {
  458. display: flex;
  459. justify-content: center;
  460. align-items: center;
  461. max-width: 100%;
  462. max-height: 270px;
  463. img {
  464. max-width: 100%;
  465. max-height: 270px;
  466. }
  467. }
  468. .imgbbx {
  469. display: flex;
  470. flex-direction: column;
  471. align-items: center;
  472. justify-content: center;
  473. width: 100%;
  474. height: 100%;
  475. i {
  476. font-weight: bold;
  477. margin: 14px 0;
  478. font-size: 24px;
  479. }
  480. }
  481. }
  482. p {
  483. margin: 5px 0px;
  484. }
  485. }
  486. </style>