index.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <style>
  2. .table-body {
  3. padding: 20px 20px;
  4. background-color: #fff;
  5. }
  6. .table-body .top-input {
  7. margin-top: 34px;
  8. }
  9. .input-item {
  10. width: 200px;
  11. margin-right: 20px;
  12. }
  13. .input-item .el-input__inner {
  14. border-right: 0;
  15. }
  16. .input-item .el-input__inner:hover {
  17. border: 1px solid #dcdfe6;
  18. border-right: 0;
  19. outline: 0;
  20. }
  21. .input-item .el-input__inner:focus {
  22. border: 1px solid #dcdfe6;
  23. border-right: 0;
  24. outline: 0;
  25. }
  26. .input-item .el-input-group__append {
  27. background-color: #fff;
  28. border-left: 0;
  29. width: 10%;
  30. padding: 0;
  31. }
  32. .input-item .el-input-group__append .el-button {
  33. padding: 0;
  34. }
  35. .input-item .el-input-group__append .el-button {
  36. margin: 0;
  37. }
  38. /* #app .table-body .el-table .el-button {
  39. border-radius: 16px;
  40. } */
  41. .create {
  42. height: 36px;
  43. line-height: 36px;
  44. float: right;
  45. color: #BCBCBC;
  46. margin-left: 20px;
  47. }
  48. .name {
  49. cursor: pointer;
  50. color: #49A9FF;
  51. }
  52. .el-input-group__append {
  53. /* background-color: #fff; */
  54. }
  55. /* 卡片 */
  56. .plugin-list {
  57. margin: 0 0 0 -20px;
  58. /* padding-right: 100px; */
  59. display: flex;
  60. flex-wrap: wrap;
  61. }
  62. .plugin-list .plugin-item {
  63. width: 20%;
  64. min-width: 400px;
  65. }
  66. .plugin-item {
  67. border: 1px solid #ebebeb;
  68. background: #FFFFFF;
  69. box-shadow: 3px 5px 15px rgba(80, 80, 80, 0.16);
  70. opacity: 1;
  71. border-radius: 5px;
  72. padding: 20px;
  73. margin: 0 0 20px 20px;
  74. transition: 250ms;
  75. position: relative;
  76. /* min-width: 300px; */
  77. }
  78. .plugin-item .item-status {
  79. position: absolute;
  80. top: 0;
  81. right: 0;
  82. width: 94px;
  83. height: 30px;
  84. background: #E8EAEC;
  85. opacity: 1;
  86. border-radius: 0px 5px 0px 5px;
  87. font-size: 14px;
  88. font-family: Microsoft YaHei;
  89. font-weight: 400;
  90. line-height: 30px;
  91. color: #9398A4;
  92. text-align: center;
  93. }
  94. .item-status-permanent {
  95. width: 94px;
  96. }
  97. .item-status-effective {
  98. width: 164px;
  99. }
  100. .plugin-item .item-info {
  101. display: flex;
  102. align-items: center;
  103. }
  104. /* .plugin-item .item-info .item-right{
  105. min-width: 500px;
  106. } */
  107. .plugin-item .item-btns {
  108. display: flex;
  109. align-items: center;
  110. justify-content: flex-end;
  111. margin-top: 12px;
  112. }
  113. .plugin-item .mall-logo {
  114. width: 70px;
  115. height: 70px;
  116. margin-right: 12px;
  117. }
  118. .plugin-item .mall-logo img {
  119. width: 100%;
  120. height: 100%;
  121. display: block;
  122. border-radius: 50%;
  123. }
  124. .plugin-item .display-name {
  125. font-size: 18pt;
  126. margin-top: 10px;
  127. margin-bottom: 4px;
  128. font-family: Microsoft YaHei;
  129. font-weight: bold;
  130. line-height: 30px;
  131. color: #3F495D;
  132. opacity: 1;
  133. width: 200px;
  134. white-space: nowrap;
  135. overflow: hidden;
  136. text-overflow: ellipsis;
  137. }
  138. .plugin-item .name {
  139. color: #909399;
  140. }
  141. .plugin-item:hover {
  142. cursor: pointer;
  143. border-color: #bfddff;
  144. }
  145. /* .plugin-item:hover .display-name {
  146. color: #409EFF;
  147. } */
  148. .plugin-item .plugin-option-btn {
  149. height: 25px;
  150. width: 25px;
  151. font-size: 12px;
  152. padding: 0;
  153. }
  154. .plugin-item .detail-option.detail-option {
  155. color: #909399;
  156. background: #F2F6FC;
  157. }
  158. .plugin-item .detail-option:hover {
  159. color: #fff;
  160. background: #909399;
  161. }
  162. .label {
  163. padding-right: 10px;
  164. }
  165. .el-collapse-item__header {
  166. color: #0A54EA;
  167. }
  168. .el-collapse-item__arrow {
  169. margin: 0;
  170. }
  171. .label_conf {
  172. line-height: 35px;
  173. margin-left: 10px;
  174. }
  175. .line_msg {
  176. width: 100%;
  177. height: 1px;
  178. background-color: #d9d6d6;
  179. margin-bottom: 20px;
  180. }
  181. .type_conf {
  182. font-weight: 600;
  183. margin-bottom: 20px;
  184. }
  185. .msg_title {
  186. padding-left: 5%;
  187. width: 12%;
  188. float: left;
  189. text-align: right;
  190. line-height: 35px;
  191. }
  192. .conf_content {
  193. width: 60%;
  194. float: left;
  195. }
  196. </style>
  197. <div id="app" v-cloak>
  198. <el-card shadow="never" style="border:0;min-width: 1200px;"
  199. body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  200. <div slot="header">
  201. <div>
  202. <span>{{cate_name}}</span>
  203. <div style="float: right; margin: -5px 0">
  204. <!-- <el-button type="primary" size="small" @click="handleEdit('')">添加标签</el-button>-->
  205. <el-button type="primary" size="small" @click="open(0)">添加标签</el-button>
  206. </div>
  207. </div>
  208. </div>
  209. <div class="table-body el-input--small">
  210. <template>
  211. <div>
  212. <el-table :data="list" style="width: 100%;margin-bottom: 20px;" row-key="id">
  213. <el-table-column
  214. label="序号"
  215. type="index"
  216. width="50"
  217. align="center"
  218. >
  219. </el-table-column>
  220. <el-table-column prop="name" label="名称" align="center">
  221. <template slot-scope="scope">
  222. <span style="margin-left: 10px">{{ scope.row.name }}</span>
  223. </template>
  224. </el-table-column>
  225. <el-table-column prop="user_num" label="会员数量" align="center">
  226. <template slot-scope="scope">
  227. <el-button type="text" @click="navUserList(scope.row.cate_id+'_'+scope.row.id)"
  228. class="all_text">
  229. <span style="margin-left: 10px; cursor: pointer;">{{ scope.row.user_num }}</span>
  230. </el-button>
  231. </template>
  232. </el-table-column>
  233. <el-table-column prop="content" label="达标条件" align="center">
  234. <template slot-scope="scope">
  235. <span style="margin-left: 10px">{{ scope.row.content }}</span>
  236. </template>
  237. </el-table-column>
  238. <el-table-column prop="content" label="标签颜色" align="center">
  239. <template slot-scope="scope">
  240. <el-color-picker v-model="scope.row.color" disabled></el-color-picker>
  241. </template>
  242. </el-table-column>
  243. <el-table-column prop="created_at" label="时间" align="center">
  244. <template slot-scope="scope">
  245. <span style="margin-left: 10px">{{ scope.row.created_at|dateTimeFormat('Y-m-d H:i:s') }}</span>
  246. </template>
  247. </el-table-column>
  248. <el-table-column label="启用状态" width="120" align="center">
  249. <template slot-scope="scope">
  250. <el-switch
  251. :active-value="1"
  252. :inactive-value="0"
  253. @change="handle('status', scope.row)"
  254. v-model="scope.row.status">
  255. </el-switch>
  256. </template>
  257. </el-table-column>
  258. <el-table-column label="操作" align="center">
  259. <template slot-scope="scope">
  260. <el-button type="text" size="mini" circle style="margin-left: 10px;margin-top: 10px"
  261. @click="open(scope.row.id)">
  262. 编辑
  263. </el-button>
  264. <el-button style="margin-left: 10px;margin-top: 10px" type="text" class="set-el-button"
  265. size="mini" circle @click="handleDelete(scope.$index, scope.row)">
  266. 删除
  267. </el-button>
  268. </template>
  269. </el-table-column>
  270. </el-table>
  271. </div>
  272. </template>
  273. <div style="text-align: right;margin: 20px 0;">
  274. </div>
  275. </div>
  276. </el-card>
  277. <el-dialog :visible.sync="dialogVisible" width="30%" :before-close="handleClose" :close-on-click-modal="false">
  278. <template>
  279. <el-form :model="ruleForm" :rules="rules" size="small" ref="ruleForm" label-width="100px"
  280. @submit.native.prevent>
  281. <el-card shadow="never">
  282. <el-col :span="50">
  283. <el-form-item label="标签名称" prop="name">
  284. <el-input v-model="ruleForm.name" placeholder="请输入标签名称,最多20个字"></el-input>
  285. </el-form-item>
  286. <el-form-item :label="content" v-if="ruleForm.cate_id!=2&&ruleForm.cate_id!=3" prop="condition.num">
  287. <el-input v-model="ruleForm.condition.num" placeholder="">
  288. <template slot="append">/ {{unit}}</template>
  289. </el-input>
  290. <span>具体值输入整数:如:1;范围,请按如下格式输入:10-100;</span>
  291. </el-form-item>
  292. <el-form-item :label="content" v-if="ruleForm.cate_id==2||ruleForm.cate_id==3">
  293. <el-select v-model="ruleForm.condition.num" placeholder="请选择" @change="selectChange">
  294. <el-option
  295. v-for="item in level_arr"
  296. :key="item.id"
  297. :label="item.name"
  298. :value="item.level">
  299. </el-option>
  300. </el-select>
  301. </el-form-item>
  302. <el-form-item label="标签颜色">
  303. <el-color-picker v-model="ruleForm.color"></el-color-picker>
  304. </el-form-item>
  305. <el-form-item label="是否启用">
  306. <el-switch v-model="ruleForm.status" :active-value="1" :inactive-value="0">
  307. </el-switch>
  308. </el-form-item>
  309. </el-col>
  310. </el-card>
  311. <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;"
  312. @click="store('ruleForm')" size="small">确 定
  313. </el-button>
  314. </el-form>
  315. </template>
  316. </el-dialog>
  317. </div>
  318. <script>
  319. new Vue({
  320. el: '#app',
  321. data() {
  322. return {
  323. dialogAddgsVisible: false,
  324. activeName: "1",
  325. list: [],
  326. pagination: null,
  327. page: 1,
  328. pageCount: 0,
  329. time: [],
  330. search: {
  331. name: '',
  332. date_start: null,
  333. date_end: null,
  334. cate_id: 1,
  335. },
  336. cate_id: 0,
  337. url: '',
  338. cate_name: '',
  339. loading: false,
  340. btnLoading: false,
  341. dialogVisible: false,
  342. ruleForm: {
  343. id: '',
  344. cate_id: 0,
  345. name: '',
  346. color: '',
  347. condition: {
  348. num: ''
  349. },
  350. status: 1,
  351. source_table: '',
  352. source_table_id: 0,
  353. },
  354. rules: {
  355. name: [{
  356. required: true,
  357. message: '请输入标签名称',
  358. trigger: 'change'
  359. },
  360. {
  361. validator: (rule, value, callback) => {
  362. if (value.length > 20 || value.length < 0) {
  363. callback('最大长度在1-20个字内');
  364. }
  365. callback();
  366. }
  367. },
  368. ],
  369. 'condition.num': [
  370. { required: true, message: '请输入具体数值', trigger: 'blur'},
  371. {
  372. validator: (rule, value, callback) => {
  373. if (value !== undefined && value !== null && value !== '') {
  374. // 处理范围值情况
  375. if (value.toString().includes('-')) {
  376. const range = value.toString().split('-');
  377. if (range.length === 2 && !isNaN(range[0]) && !isNaN(range[1]) && range[0] > 0 && range[1] > 0) {
  378. callback();
  379. } else {
  380. callback('范围格式错误,请输入类似 10-100 的格式');
  381. }
  382. } else if (parseFloat(value) <= 0) {
  383. callback(this.content + '金额必须大于0');
  384. } else {
  385. callback();
  386. }
  387. } else {
  388. callback();
  389. }
  390. }
  391. }
  392. ],
  393. },
  394. content: "",
  395. unit: "",
  396. route: "",
  397. level_arr: [],
  398. levelMap: [],
  399. label_action: "",
  400. }
  401. },
  402. created() {
  403. var url_r = window.location.search;
  404. url_r = url_r.replace('?r=', '')
  405. url_r = url_r.replace('%2F', '/')
  406. url_r = url_r.replace('%2F', '/')
  407. this.url = url_r
  408. var url_split = this.url.split('/');
  409. this.label_action = url_split[2]
  410. console.log(this.label_action,'========')
  411. this.getList({});
  412. },
  413. methods: {
  414. searchs() {
  415. this.page = 1;
  416. this.getList();
  417. },
  418. pageChange(currentPage) {
  419. let self = this;
  420. self.page = currentPage;
  421. self.getList();
  422. },
  423. getList() {
  424. let self = this;
  425. self.listLoading = true;
  426. // 检查是否选择了搜索时间
  427. if (!self.time) {
  428. self.search.date_start = '';
  429. self.search.date_end = '';
  430. } else {
  431. self.search.date_start = self.time[0];
  432. self.search.date_end = self.time[1];
  433. }
  434. request({
  435. method: 'post',
  436. params: {
  437. r: this.url,
  438. },
  439. data: {
  440. page: self.page,
  441. name: self.search.name,
  442. date_start: self.search.date_start,
  443. date_end: self.search.date_end,
  444. type: self.search.type,
  445. },
  446. }).then(e => {
  447. self.listLoading = false;
  448. self.list = e.data.data.list;
  449. this.pagination = e.data.data.pagination;
  450. this.pagination.pageSize = e.data.data.page_size;
  451. this.pagination.total_count = e.data.data.count;
  452. this.cate_id = e.data.data.cate_id;
  453. this.cate_name = e.data.data.cate_name;
  454. }).catch(e => {
  455. console.log(e);
  456. });
  457. },
  458. handle(type, data = null) {
  459. let id = data ? parseInt(data.id) : '';
  460. let status = data ? parseInt(data.status) : '';
  461. switch (type) {
  462. case 'status':
  463. let self = this;
  464. self.listLoading = true;
  465. request({
  466. params: {
  467. r: 'mall/member-label/'+ this.label_action +'-switch-status',
  468. },
  469. method: 'post',
  470. data: {
  471. id: id,
  472. status: status,
  473. }
  474. }).then(e => {
  475. self.listLoading = false;
  476. if (e.data.code === 0) {
  477. self.$message.success(e.data.msg);
  478. } else {
  479. self.$message.error(e.data.msg);
  480. }
  481. self.getList();
  482. }).catch(e => {
  483. console.log(e);
  484. });
  485. break;
  486. default:
  487. break;
  488. }
  489. },
  490. handleEdit(id) {
  491. navigateTo({
  492. r: 'mall/member-label/'+ this.label_action +'-edit',
  493. id: id,
  494. cate_id: this.cate_id,
  495. });
  496. },
  497. handleDelete(index, row) {
  498. this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {type: 'warning'}).then(() => {
  499. this.$request({
  500. params: {
  501. r: 'mall/member-label/'+ this.label_action +'-del',
  502. id: row.id,
  503. cate_id: this.cate_id,
  504. status: -1,
  505. },
  506. }).then(e => {
  507. if (e.data.code == 0) {
  508. this.$message({
  509. message: e.data.msg,
  510. type: 'success'
  511. });
  512. navigateTo({
  513. r: 'mall/member-label/' + e.data.data.route
  514. });
  515. } else {
  516. this.$message({
  517. message: e.data.msg,
  518. type: 'error'
  519. });
  520. }
  521. }).catch(e => {
  522. });
  523. });
  524. },
  525. handleClose(done) {
  526. this.ruleForm.id = 0;
  527. this.ruleForm.cate_id = '';
  528. this.ruleForm.name = '';
  529. this.ruleForm.color = '';
  530. this.ruleForm.condition = {
  531. num: '',
  532. name: ""
  533. };
  534. done();
  535. },
  536. //进行验证
  537. store(formName) {
  538. let formData = JSON.stringify(this.dataForm);
  539. //进行验证
  540. this.$refs[formName].validate((valid) => {
  541. if (valid) {
  542. this.btnLoading = true;
  543. request({
  544. params: {
  545. r: 'mall/member-label/'+ this.label_action +'-edit',
  546. },
  547. method: 'post',
  548. data: {
  549. form: this.ruleForm,
  550. }
  551. }).then(e => {
  552. this.btnLoading = false;
  553. if (e.data.code == 0) {
  554. this.$message.success(e.data.msg);
  555. this.dialogVisible = false;
  556. this.getList();
  557. } else {
  558. this.$message.error(e.data.msg);
  559. }
  560. }).catch(e => {
  561. this.$message.error(e);
  562. this.btnLoading = false;
  563. })
  564. } else {
  565. this.btnLoading = false;
  566. return false;
  567. }
  568. });
  569. },
  570. loadData(id, cate_id) {
  571. this.loading = true;
  572. request({
  573. params: {
  574. r: 'mall/member-label/'+ this.label_action +'-edit',
  575. id: id,
  576. cate_id: cate_id
  577. },
  578. method: 'get'
  579. }).then(e => {
  580. this.loading = false;
  581. if (e.data.code == 0) {
  582. if (id) {
  583. this.ruleForm = e.data.data.detail;
  584. }
  585. this.content = e.data.data.content;
  586. this.unit = e.data.data.unit;
  587. this.route = e.data.data.route;
  588. this.cate_name = e.data.data.cate_name;
  589. this.level_arr = e.data.data.level_arr;
  590. this.levelMap = e.data.data.levelMap;
  591. this.ruleForm.source_table = e.data.data.levelTable;
  592. }
  593. }).catch(e => {
  594. this.loading = false;
  595. })
  596. },
  597. open(id) {
  598. this.dialogVisible = true;
  599. this.ruleForm.id = id;
  600. this.ruleForm.cate_id = this.cate_id;
  601. this.loadData(id, this.cate_id);
  602. },
  603. navUserList(memberLabelIds) {
  604. this.$navigate({
  605. r: 'mall/user/index',
  606. memberLabelIds: memberLabelIds
  607. })
  608. },
  609. selectChange(v) {
  610. this.ruleForm.source_table_id = this.levelMap[v]
  611. }
  612. },
  613. });
  614. </script>