index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <div id="hierarchicalManagement">
  3. <table-list
  4. :tableSets="tableSet"
  5. :tableData="tableData"
  6. :navText="navText"
  7. @addClick="addClick"
  8. :loading="loading"
  9. >
  10. <template slot="btn" slot-scope="props">
  11. <el-button type="text" @click="addClick(props.scope.row, 2)"
  12. >详情</el-button
  13. >
  14. <el-button type="text" @click="addClick(props.scope.row, 0)"
  15. >修改</el-button
  16. >
  17. </template>
  18. </table-list>
  19. <pagination
  20. :total="total"
  21. :pageSize="pageSize"
  22. :currentPage="currentPage"
  23. @handleSizeChange="handleSizeChange"
  24. @handleCurrentChange="handleCurrentChange"
  25. />
  26. <el-dialog
  27. :visible.sync="dialogBox"
  28. width="1040px"
  29. :show-close="false"
  30. :destroy-on-close="true"
  31. :before-close="closeBefore"
  32. :fullscreen="fullscreen"
  33. >
  34. <div slot="title" class="hearders">
  35. <div class="leftTitle">
  36. {{ statusPop === 1 ? "添加" : statusPop === 0 ? "修改" : "详情" }}
  37. </div>
  38. <div class="rightBoxs">
  39. <img
  40. src="@/assets/images/Max@2x.png"
  41. alt=""
  42. @click="fullscreen = !fullscreen"
  43. />
  44. <img src="@/assets/images/Close@2x.png" alt="" @click="closeBefore" />
  45. </div>
  46. </div>
  47. <div style="padding: 30rpx">
  48. <el-form
  49. label-position="right"
  50. label-width="80px"
  51. :model="formLabelAlign"
  52. >
  53. <el-row>
  54. <el-col :span="24" style="display: flex; align-items: center">
  55. <el-form-item label="等级">
  56. <el-input-number
  57. v-model="formLabelAlign.grade"
  58. controls-position="right"
  59. :min="1"
  60. :max="10"
  61. size="small"
  62. ></el-input-number>
  63. </el-form-item>
  64. <el-form-item label="等级名称">
  65. <el-input
  66. v-model="formLabelAlign.gradeName"
  67. size="small"
  68. ></el-input>
  69. </el-form-item>
  70. <el-form-item label="所需积分">
  71. <div style="display: flex; align-items: center">
  72. <el-input-number
  73. v-model="formLabelAlign.needIntegralStart"
  74. controls-position="right"
  75. :min="0"
  76. size="small"
  77. ></el-input-number>
  78. ~
  79. <el-input-number
  80. v-model="formLabelAlign.needIntegralEnd"
  81. controls-position="right"
  82. :min="0"
  83. size="small"
  84. ></el-input-number></div></el-form-item
  85. ></el-col>
  86. <el-col
  87. :span="24"
  88. style="display: flex; align-items: center; flex-wrap: wrap"
  89. v-for="(item, index) in formLabelAlign.activityGradePrivilegesVo"
  90. :key="index"
  91. >
  92. <el-form-item label="等级特权">
  93. <el-select
  94. v-model="item.priType"
  95. placeholder="请选择"
  96. size="small"
  97. >
  98. <el-option
  99. v-for="items in options"
  100. :key="items.value"
  101. :label="items.label"
  102. :value="items.value"
  103. >
  104. </el-option>
  105. </el-select>
  106. </el-form-item>
  107. <el-form-item label="特权范围" v-if="item.priType !== 2">
  108. <el-select
  109. v-model="item.courseVo"
  110. placeholder="特权范围"
  111. clearable
  112. filterable
  113. multiple
  114. collapse-tags
  115. >
  116. <el-option
  117. v-for="itemz in optionsList"
  118. :key="itemz.value"
  119. :label="itemz.label"
  120. :value="itemz.value"
  121. >
  122. </el-option>
  123. </el-select>
  124. </el-form-item>
  125. <el-form-item
  126. :label="item.priType === 0 ? '优惠金额' : '折扣'"
  127. v-if="item.priType !== 2 || item.priType !== 3"
  128. >
  129. <el-input v-model="item.couponPrice" size="small">
  130. <template slot="append">¥</template></el-input
  131. ></el-form-item
  132. >
  133. <el-form-item
  134. label="有效期"
  135. v-if="item.priType !== 2 || item.priType !== 3"
  136. >
  137. <el-input v-model="item.endTimeSum" size="small"
  138. ><template slot="append">月</template></el-input
  139. ></el-form-item
  140. >
  141. <el-form-item :label="item.priType === 3 ? '课时' : '数量'">
  142. <el-input-number
  143. v-model="item.quantity"
  144. controls-position="right"
  145. :min="0"
  146. size="small"
  147. ></el-input-number
  148. ></el-form-item>
  149. <el-form-item label="操作">
  150. <el-button @click="delList(index)">删除</el-button>
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="24">
  154. <el-button @click="addList">新增</el-button>
  155. </el-col>
  156. <el-col
  157. :span="24"
  158. style="display: flex; align-items: center; flex-wrap: wrap"
  159. >
  160. <el-form-item label="备注">
  161. <el-input
  162. type="textarea"
  163. :rows="2"
  164. placeholder="请输入内容"
  165. v-model="formLabelAlign.remarks"
  166. >
  167. </el-input
  168. ></el-form-item>
  169. </el-col>
  170. </el-row>
  171. </el-form>
  172. </div>
  173. <div slot="footer" class="dialog-footer">
  174. <el-button @click="closeBefore">取 消</el-button>
  175. <el-button
  176. type="primary"
  177. @click="rulesTableSumbit"
  178. v-if="statusPop !== 2"
  179. >确 定</el-button
  180. >
  181. </div>
  182. </el-dialog>
  183. </div>
  184. </template>
  185. <script>
  186. import searchBox from "@/components/searchBox";
  187. import tableList from "@/components/tableList";
  188. import pagination from "@/components/pagination";
  189. export default {
  190. components: { searchBox, tableList, pagination },
  191. data() {
  192. return {
  193. loading: false, //当前表单加载是否加载动画
  194. navText: {
  195. title: "查出等级管理",
  196. index: 0,
  197. ch: "条",
  198. num: true,
  199. choice: true,
  200. addHide: false,
  201. backFatherBtn: {
  202. status: false,
  203. title: "未定义",
  204. },
  205. },
  206. // optionsList: [{
  207. // label: '课程',
  208. // value: 1,
  209. // children:[]
  210. // },{
  211. // label: '题库',
  212. // value: 2,
  213. // children:[]
  214. // }],
  215. optionsList: [],
  216. options: [
  217. {
  218. label: "优惠券",
  219. value: 0,
  220. },
  221. {
  222. label: "折扣券",
  223. value: 1,
  224. },
  225. {
  226. label: "解锁题库",
  227. value: 2,
  228. },
  229. {
  230. label: "解锁课程",
  231. value: 3,
  232. },
  233. ],
  234. // 表单
  235. tableSet: [
  236. {
  237. label: "等级",
  238. prop: "grade",
  239. hidden: true,
  240. },
  241. {
  242. label: "名称",
  243. prop: "gradeName",
  244. hidden: true,
  245. },
  246. {
  247. label: "所需积分",
  248. prop1: "needIntegralStart",
  249. prop2: "needIntegralEnd",
  250. hidden: true,
  251. scope: "moreLists",
  252. },
  253. {
  254. label: "用户数量",
  255. prop: "userNum",
  256. hidden: true,
  257. },
  258. {
  259. label: "备注",
  260. prop: "remarks",
  261. hidden: true,
  262. },
  263. ],
  264. formLabelAlign: {
  265. activityGradePrivilegesVo: [],
  266. },
  267. tableData: [], //表单数据
  268. total: 0, //一共多少条
  269. pageSize: 10, //每页多少条数据
  270. currentPage: 1, //当前页码
  271. statusPop: 0,
  272. fullscreen: false,
  273. dialogBox: false,
  274. };
  275. },
  276. mounted() {
  277. this.search();
  278. this.getCn();
  279. },
  280. methods: {
  281. addList() {
  282. this.formLabelAlign.activityGradePrivilegesVo.push({});
  283. },
  284. delList(v) {
  285. this.formLabelAlign.activityGradePrivilegesVo.splice(v, 1);
  286. },
  287. changeList(v) {
  288. console.log(v);
  289. },
  290. getCn() {
  291. var self = this;
  292. this.$api.inquireCourseList({ status: 1 }).then((res) => {
  293. var arrNull = [];
  294. res.rows.forEach((item, index) => {
  295. arrNull.push({ label: item.courseName, value: item.courseId });
  296. });
  297. this.optionsList = arrNull;
  298. });
  299. },
  300. search() {
  301. this.loading = true;
  302. var data = {
  303. pageSize: this.pageSize,
  304. pageNum: this.currentPage,
  305. };
  306. this.$api.inquiresystemgradeList(data).then((res) => {
  307. this.tableData = res.rows;
  308. this.total = res.total;
  309. this.navText.index = res.total;
  310. });
  311. this.loading = false;
  312. },
  313. init() {
  314. this.search();
  315. },
  316. closeBefore() {
  317. if (this.statusPop === 2) {
  318. this.dialogBox = false;
  319. this.fullscreen = false;
  320. } else {
  321. this.$confirm("此操作将关闭窗口, 是否继续?", "提示", {
  322. confirmButtonText: "确定",
  323. cancelButtonText: "取消",
  324. type: "warning",
  325. })
  326. .then(() => {
  327. this.dialogBox = false;
  328. this.fullscreen = false;
  329. this.formLabelAlign = {};
  330. })
  331. .catch(() => {});
  332. }
  333. },
  334. rulesTableSumbit() {
  335. if (
  336. this.formLabelAlign.grade === "" ||
  337. this.formLabelAlign.grade == undefined ||
  338. this.formLabelAlign.grade === null
  339. ) {
  340. this.$message.error("请输入等级");
  341. return;
  342. }
  343. if (
  344. this.formLabelAlign.gradeName === "" ||
  345. this.formLabelAlign.gradeName == undefined ||
  346. this.formLabelAlign.gradeName === null
  347. ) {
  348. this.$message.error("请输入等级名称");
  349. return;
  350. }
  351. if (
  352. this.formLabelAlign.needIntegralStart === "" ||
  353. this.formLabelAlign.needIntegralStart == undefined ||
  354. this.formLabelAlign.needIntegralStart === null
  355. ) {
  356. this.$message.error("请输入所需积分最小值");
  357. return;
  358. }
  359. if (
  360. this.formLabelAlign.needIntegralEnd === "" ||
  361. this.formLabelAlign.needIntegralEnd == undefined ||
  362. this.formLabelAlign.needIntegralEnd === null
  363. ) {
  364. this.$message.error("请输入所需积分最大值");
  365. return;
  366. }
  367. var data = {
  368. grade: this.formLabelAlign.grade,
  369. gradeName: this.formLabelAlign.gradeName,
  370. needIntegralEnd: this.formLabelAlign.needIntegralEnd,
  371. needIntegralStart: this.formLabelAlign.needIntegralStart,
  372. remarks: this.formLabelAlign.remarks,
  373. };
  374. if(this.statusPop === 1){
  375. data.activityGradePrivilegeAddBos = this.formLabelAlign.activityGradePrivilegesVo
  376. this.$api.addsystemgrade(data).then(res => {
  377. if(res.code === 200){
  378. this.$message.success('新增成功')
  379. this.search()
  380. this.dialogBox = false
  381. }
  382. })
  383. }else{
  384. data.activityGradePrivilegeEditBos = this.formLabelAlign.activityGradePrivilegesVo
  385. data.id = this.formLabelAlign.id
  386. this.$api.editsystemgrade(data).then(res => {
  387. if(res.code === 200){
  388. this.$message.success('修改成功')
  389. this.search()
  390. this.dialogBox = false
  391. }
  392. })
  393. }
  394. },
  395. addClick(v, int) {
  396. if (int === undefined) {
  397. this.statusPop = 1;
  398. this.formLabelAlign = {
  399. activityGradePrivilegesVo: [],
  400. };
  401. } else {
  402. this.$api.obtainsystemgrade(v.id).then((res) => {
  403. if (res.code === 200) {
  404. this.formLabelAlign = res.data;
  405. this.formLabelAlign.activityGradePrivilegesVo.forEach(
  406. (item, index) => {
  407. item.priType = Number(item.priType);
  408. }
  409. );
  410. }
  411. });
  412. this.statusPop = int;
  413. }
  414. this.dialogBox = true;
  415. },
  416. handleSizeChange(v) {
  417. this.pageSize = v;
  418. this.currentPage = 1;
  419. this.search();
  420. },
  421. handleCurrentChange(v) {
  422. this.currentPage = v;
  423. this.search();
  424. },
  425. },
  426. };
  427. </script>
  428. <style lang="less" scoped>
  429. /deep/.el-button {
  430. border-radius: 8px;
  431. }
  432. /deep/.el-dialog {
  433. border-radius: 8px;
  434. .el-dialog__header {
  435. padding: 0;
  436. .hearders {
  437. height: 40px;
  438. display: flex;
  439. align-items: center;
  440. justify-content: space-between;
  441. padding: 0px 18px 0px 20px;
  442. border-bottom: 1px solid #e2e2e2;
  443. .leftTitle {
  444. font-size: 14px;
  445. font-weight: bold;
  446. color: #2f4378;
  447. }
  448. .rightBoxs {
  449. display: flex;
  450. align-items: center;
  451. img {
  452. width: 14px;
  453. height: 14px;
  454. margin-left: 13px;
  455. cursor: pointer;
  456. }
  457. }
  458. }
  459. }
  460. .el-dialog__footer {
  461. padding: 0;
  462. .dialog-footer {
  463. padding: 0px 40px;
  464. height: 70px;
  465. border-top: 1px solid #e2e2e2;
  466. display: flex;
  467. align-items: center;
  468. justify-content: flex-end;
  469. }
  470. }
  471. }
  472. .imgBox {
  473. width: 100%;
  474. // height: 210px;
  475. border: 1px solid #e2e2e2;
  476. border-radius: 8px;
  477. padding: 8px 8px 3px;
  478. display: flex;
  479. flex-direction: column;
  480. align-items: center;
  481. .imgLabel {
  482. flex: 1;
  483. width: 100%;
  484. border: 1px dotted #e2e2e2;
  485. color: #999;
  486. font-size: 14px;
  487. cursor: pointer;
  488. border-radius: 8px;
  489. .msPhoto {
  490. display: flex;
  491. justify-content: center;
  492. align-items: center;
  493. max-width: 100%;
  494. max-height: 270px;
  495. img {
  496. max-width: 100%;
  497. max-height: 270px;
  498. }
  499. }
  500. .imgbbx {
  501. display: flex;
  502. flex-direction: column;
  503. align-items: center;
  504. justify-content: center;
  505. width: 100%;
  506. height: 100%;
  507. i {
  508. font-weight: bold;
  509. margin: 14px 0;
  510. font-size: 24px;
  511. }
  512. }
  513. }
  514. p {
  515. margin: 5px 0px;
  516. }
  517. }
  518. .avatar-uploader .el-upload {
  519. border: 1px dashed #d9d9d9;
  520. border-radius: 6px;
  521. cursor: pointer;
  522. position: relative;
  523. overflow: hidden;
  524. }
  525. .avatar-uploader .el-upload:hover {
  526. border-color: #409eff;
  527. }
  528. .avatar-uploader-icon {
  529. font-size: 28px;
  530. color: #8c939d;
  531. width: 178px;
  532. height: 178px;
  533. line-height: 178px;
  534. text-align: center;
  535. }
  536. .avatar {
  537. width: 178px;
  538. height: 178px;
  539. display: block;
  540. }
  541. </style>