index.vue 13 KB

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