index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  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. options: [
  92. {
  93. label: "全部状态",
  94. value: "0,1",
  95. },
  96. {
  97. label: "有效",
  98. value: 1,
  99. },
  100. {
  101. label: "无效",
  102. value: 0,
  103. },
  104. ],
  105. },
  106. {
  107. prop: "goodsStatus",
  108. placeholder: "前台可售状态",
  109. scope: "select",
  110. options: [
  111. {
  112. label: "已上架",
  113. value: 1,
  114. },
  115. {
  116. label: "未上架",
  117. value: 0,
  118. },
  119. ],
  120. },
  121. {
  122. prop1: "validityStartTime",
  123. prop2: "validityEndTime",
  124. placeholder1: "商品有效期开始时间",
  125. placeholder2: "商品有效期结束时间",
  126. scope: "moreDataPicker",
  127. },
  128. // {
  129. // prop: "orderGoodsStatus",
  130. // placeholder: "退款状态",
  131. // scope: "select",
  132. // options: [
  133. // {
  134. // label: "已退款",
  135. // value: 1,
  136. // },
  137. // {
  138. // label: "退款中",
  139. // value: 2,
  140. // },
  141. // {
  142. // label: "拒绝退款",
  143. // value: 3,
  144. // },
  145. // ],
  146. // },
  147. {
  148. prop: "goodsName",
  149. placeholder: "请输入商品名称",
  150. },
  151. ],
  152. formData: {
  153. goodsType: '',
  154. status: "0,1",
  155. pageSize: 10,
  156. pageNum: 1,
  157. },
  158. // 表单
  159. tableSet: [
  160. {
  161. label: "商品名称",
  162. prop: "goodsName",
  163. scope: "editInfo",
  164. hidden: true,
  165. },
  166. {
  167. label: "商品编码",
  168. prop: "code",
  169. hidden: true,
  170. },
  171. {
  172. label: "专业",
  173. prop: "categoryName",
  174. hidden: true,
  175. },
  176. {
  177. label: "院校",
  178. prop: "schoolName",
  179. hidden: true,
  180. },
  181. {
  182. label: "业务层次",
  183. prop1: "projectName",
  184. prop2: "businessName",
  185. hidden: true,
  186. width:"220px",
  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. width: "220px",
  223. Diszing: false,
  224. hidden: true,
  225. },
  226. {
  227. label: "学习有效期",
  228. prop1: "studyStartTime",
  229. prop2: "studyEndTime",
  230. scope: "TimeLists",
  231. width: "220px",
  232. Diszing: false,
  233. hidden: true,
  234. },
  235. {
  236. label: "供应方(服务)",
  237. prop: "supplyName",
  238. hidden: true,
  239. },
  240. {
  241. label: "最后编辑时间",
  242. prop: "updateTime",
  243. hidden: true,
  244. scope: "aTimeList",
  245. },
  246. {
  247. label: "创建时间",
  248. prop: "createTime",
  249. hidden: true,
  250. scope: "aTimeList",
  251. },
  252. {
  253. label: "可售状态",
  254. prop: "goodsStatus",
  255. hidden: true,
  256. scope: "status",
  257. },
  258. ],
  259. tableData: [], //表单数据
  260. total: 0, //一共多少条
  261. };
  262. },
  263. mounted() {
  264. this.search();
  265. },
  266. activated(){
  267. this.search()
  268. },
  269. methods: {
  270. editInfo(v) {
  271. this.addClick(v, 0);
  272. },
  273. search(int) {
  274. this.loading = true;
  275. if (int === 1) {
  276. this.formData.pageNum = 1;
  277. }
  278. if (int === 2) {
  279. this.formData = {
  280. goodsType: '',
  281. status: "0,1",
  282. pageSize: 10,
  283. pageNum: 1,
  284. };
  285. }
  286. if(int === 3){
  287. this.formData.pageNum = 1
  288. }
  289. var data = JSON.parse(JSON.stringify(this.formData))
  290. if (this.formData.validityStartTime) {
  291. data.validityStartTime = data.validityStartTime / 1000
  292. }
  293. if (this.formData.validityEndTime) {
  294. data.validityEndTime = data.validityEndTime / 1000
  295. }
  296. this.$api.inquireGoods(data).then((res) => {
  297. this.tableData = res.rows;
  298. this.total = res.total;
  299. this.navText.index = res.total;
  300. }).finally(()=>{
  301. this.loading = false;
  302. })
  303. },
  304. init() {
  305. this.search(2);
  306. },
  307. del(v) {
  308. this.$alert(
  309. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  310. "提示",
  311. {
  312. dangerouslyUseHTMLString: true,
  313. }
  314. )
  315. .then(() => {
  316. var data = {
  317. goodsId: v.goodsId,
  318. status: -1,
  319. };
  320. this.$api.editGoods(data).then((res) => {
  321. this.$message.success("删除成功");
  322. this.search();
  323. });
  324. })
  325. .catch(() => {
  326. this.$message({
  327. type: "info",
  328. message: "已取消删除",
  329. });
  330. });
  331. },
  332. addClick(v, int) {
  333. if (v === undefined) {
  334. this.$router.push({
  335. path: "commodityManageMentAdd",
  336. });
  337. } else {
  338. this.$router.push({
  339. path: "commodityManageMentEdit",
  340. query: {
  341. id: v.goodsId,
  342. },
  343. });
  344. }
  345. },
  346. handleSizeChange(v) {
  347. this.formData.pageSize = v;
  348. this.formData.pageNum = 1;
  349. this.search();
  350. },
  351. handleCurrentChange(v) {
  352. this.formData.pageNum = v;
  353. this.search();
  354. },
  355. changeStatus(item) {
  356. var items = JSON.parse(JSON.stringify(item))
  357. items.goodsStatus = items.goodsStatus === 1 ? 0 : 1;
  358. this.$api
  359. .editGoods(items)
  360. .then((res) => {
  361. if (item.goodsStatus === 1) {
  362. this.$message.success("下架成功");
  363. } else {
  364. this.$message.success("上架成功");
  365. }
  366. this.search();
  367. });
  368. },
  369. },
  370. };
  371. </script>
  372. <style lang="less" scoped>
  373. /deep/.el-button {
  374. border-radius: 8px;
  375. }
  376. /deep/.el-dialog {
  377. border-radius: 8px;
  378. .el-dialog__header {
  379. padding: 0;
  380. .hearders {
  381. height: 40px;
  382. display: flex;
  383. align-items: center;
  384. justify-content: space-between;
  385. padding: 0px 18px 0px 20px;
  386. border-bottom: 1px solid #e2e2e2;
  387. .leftTitle {
  388. font-size: 14px;
  389. font-weight: bold;
  390. color: #2f4378;
  391. }
  392. .rightBoxs {
  393. display: flex;
  394. align-items: center;
  395. img {
  396. width: 14px;
  397. height: 14px;
  398. margin-left: 13px;
  399. cursor: pointer;
  400. }
  401. }
  402. }
  403. }
  404. .el-dialog__footer {
  405. padding: 0;
  406. .dialog-footer {
  407. padding: 0px 40px;
  408. height: 70px;
  409. border-top: 1px solid #e2e2e2;
  410. display: flex;
  411. align-items: center;
  412. justify-content: flex-end;
  413. }
  414. }
  415. }
  416. .imgBox {
  417. width: 100%;
  418. // height: 210px;
  419. border: 1px solid #e2e2e2;
  420. border-radius: 8px;
  421. padding: 8px 8px 3px;
  422. display: flex;
  423. flex-direction: column;
  424. align-items: center;
  425. .imgLabel {
  426. flex: 1;
  427. width: 100%;
  428. border: 1px dotted #e2e2e2;
  429. color: #999;
  430. font-size: 14px;
  431. cursor: pointer;
  432. border-radius: 8px;
  433. .msPhoto {
  434. display: flex;
  435. justify-content: center;
  436. align-items: center;
  437. max-width: 100%;
  438. max-height: 270px;
  439. img {
  440. max-width: 100%;
  441. max-height: 270px;
  442. }
  443. }
  444. .imgbbx {
  445. display: flex;
  446. flex-direction: column;
  447. align-items: center;
  448. justify-content: center;
  449. width: 100%;
  450. height: 100%;
  451. i {
  452. font-weight: bold;
  453. margin: 14px 0;
  454. font-size: 24px;
  455. }
  456. }
  457. }
  458. p {
  459. margin: 5px 0px;
  460. }
  461. }
  462. </style>