index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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. ref="tableList"
  13. :tableSets="tableSet"
  14. :tableData="tableData"
  15. :navText="navText"
  16. @addClick="addClick"
  17. :loading="loading"
  18. @editInfo="editInfo"
  19. @openClassNum="openClassNum"
  20. rowKey="goodsId"
  21. >
  22. <template slot="customize">
  23. <el-button size="medium" @click="handelBatch(1)" type="success"
  24. >批量上架</el-button
  25. ><el-button size="medium" @click="handelBatch(0)" type="success"
  26. >批量下架</el-button
  27. ><el-button size="medium" @click="handelBatch(2)" type="warning"
  28. >批量删除</el-button
  29. >
  30. </template>
  31. <template slot="btn" slot-scope="props">
  32. <el-button
  33. v-if="
  34. props.scope.row.goodsType == 1 &&
  35. props.scope.row.courseNum &&
  36. props.scope.row.courseNum > 0 &&
  37. props.scope.row.goodsLearningOrder == 0
  38. "
  39. type="text"
  40. @click="setTeacher(props.scope.row)"
  41. >双师制设置</el-button
  42. >
  43. <el-button type="text" @click="addClick(props.scope.row, 0)"
  44. >修改</el-button
  45. >
  46. <el-button type="text" @click="changeStatus(props.scope.row)">{{
  47. props.scope.row.goodsStatus === 1 ? "下架" : "上架"
  48. }}</el-button>
  49. <el-button type="text" @click="del(props.scope.row)">删除</el-button>
  50. </template>
  51. </table-list>
  52. <pagination
  53. :total="total"
  54. :pageSize="formData.pageSize"
  55. :currentPage="formData.pageNum"
  56. @handleSizeChange="handleSizeChange"
  57. @handleCurrentChange="handleCurrentChange"
  58. />
  59. <el-dialog
  60. :visible.sync="dialogVisible"
  61. width="1000px"
  62. :show-close="false"
  63. :close-on-click-modal="false"
  64. >
  65. <div slot="title" class="hearders">
  66. <div class="leftTitle">关联商品规格</div>
  67. <div class="rightBoxs">
  68. <img
  69. src="@/assets/images/Close@2x.png"
  70. alt=""
  71. @click="dialogVisible = false"
  72. />
  73. </div>
  74. </div>
  75. <table-list
  76. :tableSets="dialogTableSet"
  77. :tableData="dialogTableData"
  78. :navText="dialogNavText"
  79. :radio.sync="tableRadio"
  80. >
  81. </table-list>
  82. <span slot="footer" class="dialog-footer">
  83. <el-button @click="dialogVisible = false">取 消</el-button>
  84. <el-button type="primary" @click="submit">确 定</el-button>
  85. </span>
  86. </el-dialog>
  87. </div>
  88. </template>
  89. <script>
  90. import searchBoxNew from "@/components/searchBoxNew";
  91. import tableList from "@/components/tableList";
  92. import pagination from "@/components/pagination";
  93. import {
  94. getGoodsSpecList,
  95. goodsUpdateSpec,
  96. goodsUpdateStatus,
  97. goodsDel,
  98. } from "@/api/resource/good";
  99. export default {
  100. name: "CommodityManageMent",
  101. components: { searchBoxNew, tableList, pagination },
  102. data() {
  103. return {
  104. loading: false, //当前表单加载是否加载动画
  105. navText: {
  106. title: "商品列表",
  107. index: 0,
  108. ch: "条",
  109. num: false,
  110. border: true,
  111. choice: true,
  112. addHide: false,
  113. changeWidth: "180px",
  114. openCheckMore: true,
  115. backFatherBtn: {
  116. status: false,
  117. title: "未定义",
  118. },
  119. },
  120. topType: true,
  121. //搜索
  122. formList: [
  123. {
  124. prop: "educationTypeId",
  125. placeholder: "教育类型",
  126. scope: "educationType",
  127. },
  128. {
  129. prop: "businessId",
  130. placeholder: "业务层次",
  131. scope: "businessLevel",
  132. edu: "educationTypeId",
  133. },
  134. {
  135. prop: "schoolId",
  136. placeholder: "院校",
  137. scope: "schoolList",
  138. edu: "educationTypeId",
  139. },
  140. {
  141. prop: "majorId",
  142. placeholder: "专业",
  143. scope: "Professional",
  144. edu: "educationTypeId",
  145. },
  146. {
  147. prop: "subjectId",
  148. placeholder: "科目",
  149. scope: "sujectType",
  150. edu: "educationTypeId",
  151. },
  152. {
  153. prop: "status",
  154. placeholder: "商品状态",
  155. scope: "select",
  156. noClear: false,
  157. options: [
  158. {
  159. label: "全部状态",
  160. value: "0,1",
  161. },
  162. {
  163. label: "有效",
  164. value: 1,
  165. },
  166. {
  167. label: "无效",
  168. value: 0,
  169. },
  170. ],
  171. },
  172. {
  173. prop: "goodsStatus",
  174. placeholder: "前台可售状态",
  175. scope: "select",
  176. options: [
  177. {
  178. label: "已上架",
  179. value: 1,
  180. },
  181. {
  182. label: "未上架",
  183. value: 0,
  184. },
  185. ],
  186. },
  187. {
  188. prop1: "validityStartTime",
  189. prop2: "validityEndTime",
  190. placeholder1: "商品有效期开始时间",
  191. placeholder2: "商品有效期结束时间",
  192. scope: "moreDataPicker",
  193. },
  194. // {
  195. // prop: "orderGoodsStatus",
  196. // placeholder: "退款状态",
  197. // scope: "select",
  198. // options: [
  199. // {
  200. // label: "已退款",
  201. // value: 1,
  202. // },
  203. // {
  204. // label: "退款中",
  205. // value: 2,
  206. // },
  207. // {
  208. // label: "拒绝退款",
  209. // value: 3,
  210. // },
  211. // ],
  212. // },
  213. {
  214. prop: "goodsName",
  215. placeholder: "请输入商品名称",
  216. },
  217. ],
  218. formData: {
  219. goodsType: "",
  220. status: "0,1",
  221. pageSize: 10,
  222. pageNum: 1,
  223. },
  224. // 表单
  225. tableSet: [
  226. {
  227. label: "商品名称",
  228. prop: "goodsName",
  229. scope: "editInfo",
  230. hidden: true,
  231. },
  232. {
  233. label: "商品编码",
  234. prop: "code",
  235. hidden: false,
  236. },
  237. {
  238. label: "专业",
  239. prop: "categoryName",
  240. hidden: true,
  241. },
  242. {
  243. label: "院校",
  244. prop: "schoolName",
  245. hidden: false,
  246. },
  247. {
  248. label: "科目",
  249. prop: "subjectNames",
  250. hidden: true,
  251. },
  252. {
  253. label: "关联商品规格",
  254. prop: "specTemplateNumber",
  255. hidden: true,
  256. scope: "aboutClassNum",
  257. },
  258. {
  259. label: "业务层次",
  260. prop1: "projectName",
  261. prop2: "businessName",
  262. hidden: false,
  263. scope: "InfoMore",
  264. },
  265. {
  266. label: "教育类型",
  267. prop: "educationName",
  268. hidden: false,
  269. },
  270. {
  271. label: "学时",
  272. prop: "classHours",
  273. hidden: true,
  274. },
  275. {
  276. label: "商品内容视图",
  277. hidden: true,
  278. scope: "treeWatch",
  279. },
  280. {
  281. label: "商品价格",
  282. prop: "standPrice",
  283. hidden: true,
  284. scope: "leftCh",
  285. ch: "¥",
  286. },
  287. {
  288. label: "商品划线价",
  289. prop: "linePrice",
  290. hidden: true,
  291. scope: "leftCh",
  292. ch: "¥",
  293. },
  294. {
  295. label: "商品状态",
  296. prop: "status",
  297. hidden: false,
  298. scope: "hasTime",
  299. },
  300. {
  301. label: "商品有效期",
  302. prop1: "validityStartTime",
  303. prop2: "validityEndTime",
  304. scope: "TimeLists",
  305. Diszing: false,
  306. hidden: true,
  307. },
  308. {
  309. label: "学习服务期",
  310. prop1: "serviceTimeType",
  311. prop2: "serviceTimeNum",
  312. prop3: "studyStartTime",
  313. prop4: "studyEndTime",
  314. scope: "studentServicePeriod",
  315. hidden: true,
  316. },
  317. {
  318. label: "供应方(服务)",
  319. prop: "supplyName",
  320. hidden: false,
  321. },
  322. {
  323. label: "最后编辑时间",
  324. prop: "updateTime",
  325. hidden: true,
  326. scope: "aTimeList",
  327. },
  328. {
  329. label: "创建时间",
  330. prop: "createTime",
  331. hidden: true,
  332. scope: "aTimeList",
  333. },
  334. {
  335. label: "可售状态",
  336. prop: "goodsStatus",
  337. hidden: true,
  338. scope: "status",
  339. },
  340. ],
  341. tableData: [], //表单数据
  342. total: 0, //一共多少条
  343. dialogVisible: false,
  344. dialogTableSet: [
  345. {
  346. label: "教育类型",
  347. prop: "educationName",
  348. hidden: true,
  349. },
  350. {
  351. label: "业务层次",
  352. prop: "businessName",
  353. hidden: true,
  354. },
  355. {
  356. label: "商品规格模板名称",
  357. prop: "name",
  358. hidden: true,
  359. },
  360. {
  361. label: "商品规格数量",
  362. prop: "specNumber",
  363. hidden: true,
  364. },
  365. ],
  366. dialogTableData: [{}],
  367. dialogNavText: {
  368. index: 0,
  369. num: false,
  370. border: true,
  371. choice: false,
  372. choiceRadio: true,
  373. radioKey: "specTemplateId",
  374. radioFixed: false,
  375. addHide: !false,
  376. tableHide: true,
  377. dontNum: true,
  378. headShow: false,
  379. backFatherBtn: {
  380. status: false,
  381. title: "未定义",
  382. },
  383. },
  384. tableRadio: "",
  385. activeGoodsId: {},
  386. };
  387. },
  388. mounted() {
  389. this.search();
  390. },
  391. activated() {
  392. this.search();
  393. },
  394. methods: {
  395. // 批量上下架
  396. handelBatch(type) {
  397. let len = this.$refs.tableList.allCheckData.length;
  398. if (!len) {
  399. return this.$message.warning("请先勾选商品");
  400. }
  401. let name = ["上架", "下架", "删除"][type];
  402. this.$confirm(`此操作将所勾选的${len}条商品${name}, 是否继续?`, "提示", {
  403. confirmButtonText: "确定",
  404. cancelButtonText: "取消",
  405. type: "warning",
  406. })
  407. .then(() => {
  408. const goodsIds = this.$refs.tableList.allCheckData.map(
  409. (item) => item.goodsId
  410. );
  411. if (type == 2) {
  412. goodsDel({
  413. status: -1,
  414. ids: goodsIds,
  415. }).then((res) => {
  416. this.$message.success("批量删除成功");
  417. this.$refs.tableList.clearMoreActive();
  418. this.search(1);
  419. });
  420. } else {
  421. goodsUpdateStatus({
  422. goodsStatus: type,
  423. goodsIds,
  424. }).then((res) => {
  425. this.$message.success(`批量${name}成功`);
  426. this.$refs.tableList.clearMoreActive();
  427. this.search(1);
  428. });
  429. }
  430. })
  431. .catch(() => {});
  432. },
  433. openClassNum(id) {
  434. this.activeGoodsId = id;
  435. let { specTemplateId } = this.tableData.find((e) => e.goodsId == id);
  436. this.tableRadio = specTemplateId || "";
  437. getGoodsSpecList(id).then((res) => {
  438. this.dialogTableData = res.data;
  439. });
  440. this.dialogVisible = true;
  441. },
  442. editInfo(v) {
  443. this.addClick(v, 0);
  444. },
  445. search(int) {
  446. this.loading = true;
  447. if (int === 1) {
  448. this.formData.pageNum = 1;
  449. }
  450. if (int === 2) {
  451. this.formData = {
  452. goodsType: "",
  453. status: "0,1",
  454. pageSize: 10,
  455. pageNum: 1,
  456. };
  457. }
  458. if (int === 3) {
  459. this.formData.pageNum = 1;
  460. }
  461. var data = JSON.parse(JSON.stringify(this.formData));
  462. if (this.formData.validityStartTime) {
  463. data.validityStartTime = data.validityStartTime / 1000;
  464. }
  465. if (this.formData.validityEndTime) {
  466. data.validityEndTime = data.validityEndTime / 1000;
  467. }
  468. this.$api
  469. .inquireGoods(data)
  470. .then((res) => {
  471. this.tableData = res.rows;
  472. this.total = res.total;
  473. this.navText.index = res.total;
  474. })
  475. .finally(() => {
  476. this.loading = false;
  477. });
  478. },
  479. init() {
  480. this.search(2);
  481. },
  482. del(v) {
  483. this.$api.gradecheckGoodsChange({ goodsId: v.goodsId }).then((res) => {
  484. if (res.data > 0) {
  485. this.$message.error("已有学员正在学习该商品,无法删除");
  486. return;
  487. } else {
  488. this.$alert(
  489. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  490. "提示",
  491. {
  492. dangerouslyUseHTMLString: true,
  493. }
  494. )
  495. .then(() => {
  496. var data = {
  497. goodsId: v.goodsId,
  498. status: -1,
  499. };
  500. this.$api.editGoods(data).then((res) => {
  501. this.$message.success("删除成功");
  502. this.search();
  503. });
  504. })
  505. .catch(() => {
  506. this.$message({
  507. type: "info",
  508. message: "已取消删除",
  509. });
  510. });
  511. }
  512. });
  513. },
  514. //双师制设置
  515. setTeacher(data) {
  516. const jump = () => {
  517. this.$router.push({
  518. path: "commoditySetTeacher",
  519. query: {
  520. id: data.goodsId,
  521. },
  522. });
  523. };
  524. const statusPage = this.$store.state.tagsView.visitedViews.some(
  525. (item) => {
  526. return item.name == "CommoditySetTeacher";
  527. }
  528. );
  529. if (statusPage) {
  530. this.$store
  531. .dispatch("tagsView/delCachedView", {
  532. name: "CommoditySetTeacher",
  533. })
  534. .then((res) => {
  535. jump();
  536. });
  537. } else {
  538. jump();
  539. }
  540. },
  541. addClick(v, int) {
  542. if (v === undefined) {
  543. this.$router.push({
  544. path: "commodityManageMentAdd",
  545. });
  546. } else {
  547. const jump = () => {
  548. this.$router.push({
  549. path: "commodityManageMentEdit",
  550. query: {
  551. id: v.goodsId,
  552. },
  553. });
  554. };
  555. const statusPage = this.$store.state.tagsView.visitedViews.some(
  556. (item) => {
  557. return item.name == "CommodityManageMentEdit";
  558. }
  559. );
  560. if (statusPage) {
  561. this.$store
  562. .dispatch("tagsView/delCachedView", {
  563. name: "CommodityManageMentEdit",
  564. })
  565. .then((res) => {
  566. jump();
  567. });
  568. } else {
  569. jump();
  570. }
  571. }
  572. },
  573. handleSizeChange(v) {
  574. this.formData.pageSize = v;
  575. this.formData.pageNum = 1;
  576. this.search();
  577. },
  578. handleCurrentChange(v) {
  579. this.formData.pageNum = v;
  580. this.search();
  581. },
  582. changeStatus(item) {
  583. var items = JSON.parse(JSON.stringify(item));
  584. items.goodsStatus = items.goodsStatus === 1 ? 0 : 1;
  585. this.$api.editGoods(items).then((res) => {
  586. if (item.goodsStatus === 1) {
  587. this.$message.success("下架成功");
  588. } else {
  589. this.$message.success("上架成功");
  590. }
  591. this.search();
  592. });
  593. },
  594. submit() {
  595. if (!this.tableRadio) {
  596. return this.$message({
  597. message: "请选择关联商品规格",
  598. type: "warning",
  599. });
  600. }
  601. goodsUpdateSpec({
  602. goodsId: this.activeGoodsId,
  603. specTemplateId: this.tableRadio,
  604. }).then((res) => {
  605. this.dialogVisible = false;
  606. this.search();
  607. });
  608. },
  609. },
  610. };
  611. </script>
  612. <style lang="less" scoped>
  613. /deep/.el-button {
  614. border-radius: 8px;
  615. }
  616. /deep/.el-dialog {
  617. border-radius: 8px;
  618. .el-dialog__header {
  619. padding: 0;
  620. .hearders {
  621. height: 40px;
  622. display: flex;
  623. align-items: center;
  624. justify-content: space-between;
  625. padding: 0px 18px 0px 20px;
  626. border-bottom: 1px solid #e2e2e2;
  627. .leftTitle {
  628. font-size: 14px;
  629. font-weight: bold;
  630. color: #2f4378;
  631. }
  632. .rightBoxs {
  633. display: flex;
  634. align-items: center;
  635. img {
  636. width: 14px;
  637. height: 14px;
  638. margin-left: 13px;
  639. cursor: pointer;
  640. }
  641. }
  642. }
  643. }
  644. .el-dialog__footer {
  645. padding: 0;
  646. .dialog-footer {
  647. padding: 0px 40px;
  648. height: 70px;
  649. border-top: 1px solid #e2e2e2;
  650. display: flex;
  651. align-items: center;
  652. justify-content: flex-end;
  653. }
  654. }
  655. }
  656. .imgBox {
  657. width: 100%;
  658. // height: 210px;
  659. border: 1px solid #e2e2e2;
  660. border-radius: 8px;
  661. padding: 8px 8px 3px;
  662. display: flex;
  663. flex-direction: column;
  664. align-items: center;
  665. .imgLabel {
  666. flex: 1;
  667. width: 100%;
  668. border: 1px dotted #e2e2e2;
  669. color: #999;
  670. font-size: 14px;
  671. cursor: pointer;
  672. border-radius: 8px;
  673. .msPhoto {
  674. display: flex;
  675. justify-content: center;
  676. align-items: center;
  677. max-width: 100%;
  678. max-height: 270px;
  679. img {
  680. max-width: 100%;
  681. max-height: 270px;
  682. }
  683. }
  684. .imgbbx {
  685. display: flex;
  686. flex-direction: column;
  687. align-items: center;
  688. justify-content: center;
  689. width: 100%;
  690. height: 100%;
  691. i {
  692. font-weight: bold;
  693. margin: 14px 0;
  694. font-size: 24px;
  695. }
  696. }
  697. }
  698. p {
  699. margin: 5px 0px;
  700. }
  701. }
  702. </style>