edit.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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. </style>
  163. <?php
  164. use common\helpers\ComponentHelper;
  165. ComponentHelper::loadComponentView('com-dialog-select');
  166. ComponentHelper::loadComponentView('com-dialog-select-store');
  167. ComponentHelper::loadComponentView('com-image');
  168. ?>
  169. <div id="app" v-cloak>
  170. <el-card shadow="never" style="border:0;min-width: 1200px;"
  171. body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  172. <div slot="header">
  173. <div>
  174. <span>添加会员等级</span>
  175. </div>
  176. </div>
  177. <div class="table-body">
  178. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" @close="handleClose('ruleForm')">
  179. <el-form-item label="等级权重" :label-width="formLabelWidth" prop="level">
  180. <el-select style="width: 100%" v-model="ruleForm.level" placeholder="请选择">
  181. <el-option
  182. v-for="item in options"
  183. :key="item.level"
  184. :label="item.name"
  185. :value="item.level"
  186. :disabled="item.disabled && item.level!=origin_level">
  187. </el-option>
  188. </el-select>
  189. </el-form-item>
  190. <el-form-item label="会员名称" :label-width="formLabelWidth" prop="name">
  191. <el-input v-model="ruleForm.name" autocomplete="off"></el-input>
  192. </el-form-item>
  193. <el-form-item :label-width="formLabelWidth" prop="discount">
  194. <template slot='label'>
  195. <span>折扣</span>
  196. <el-tooltip effect="dark" content="请输入0.1~10之间的数字"
  197. placement="top">
  198. <i class="el-icon-info"></i>
  199. </el-tooltip>
  200. </template>
  201. <el-input placeholder="请输入折扣" min="0" max="10" type="number" v-model="ruleForm.discount"
  202. auto-complete="off">
  203. <template slot="append">折</template>
  204. </el-input>
  205. </el-form-item>
  206. <el-form-item label="状态" prop="status" :label-width="formLabelWidth">
  207. <el-switch v-model="ruleForm.status" active-value="1" inactive-value="0" active-text="开启"
  208. inactive-text="关闭">
  209. </el-switch>
  210. </el-form-item>
  211. <el-form-item label="会员图标" prop="pic_url" :label-width="formLabelWidth">
  212. <com-attachment :multiple="false" :max="1" @selected="picUrl">
  213. <el-tooltip class="item" effect="dark" content="建议尺寸44*44" placement="top">
  214. <el-button size="mini">选择文件</el-button>
  215. </el-tooltip>
  216. </com-attachment>
  217. <com-image width="80px" height="80px" mode="aspectFill" :src="ruleForm.pic_url"></com-image>
  218. </el-form-item>
  219. <el-form-item label="是否启用自动升级" prop="is_auto_upgrade" :label-width="formLabelWidth">
  220. <el-switch v-model="ruleForm.is_auto_upgrade" :active-value="1" :inactive-value="0" active-text="开启"
  221. inactive-text="关闭">
  222. </el-switch>
  223. </el-form-item>
  224. <template v-if="ruleForm.is_auto_upgrade == 1">
  225. <?php echo $tpl; ?>
  226. </template>
  227. <el-form-item label="购买指定分类的任意产品升级" prop="cate_ids">
  228. <el-radio-group v-model="ruleForm.buy_cate_type">
  229. <el-radio :label="0">订单完成</el-radio>
  230. <el-radio :label="1">支付完成</el-radio>
  231. </el-radio-group>
  232. <el-cascader size="small" v-model="ruleForm.cate_ids" :options="good_cate_list" :props="{ multiple: true,checkStrictly: true,emitPath: false, }" clearable></el-cascader>
  233. </el-form-item>
  234. <el-form-item label="会员权益(多条)" prop="benefits" style="padding-right: 0">
  235. <el-table
  236. style="margin-bottom: 15px;"
  237. v-if="ruleForm.benefits.length > 0"
  238. :data="ruleForm.benefits"
  239. border
  240. style="width: 100%;">
  241. <el-table-column
  242. label="权益标题"
  243. width="180">
  244. <template slot-scope="scope">
  245. <el-input v-model="scope.row.title" placeholder="请输入标题"></el-input>
  246. </template>
  247. </el-table-column>
  248. <el-table-column
  249. label="权益图标"
  250. width="180">
  251. <template slot-scope="scope">
  252. <div flex="box:first">
  253. <div flex="cross:center" style="margin-right: 10px;">
  254. <com-attachment :multiple="false" :params="scope.row" :max="1"
  255. @selected="benefitsPicUrl">
  256. <el-tooltip class="item" effect="dark" content="建议尺寸80*80" placement="top">
  257. <el-button size="mini">选择图片</el-button>
  258. </el-tooltip>
  259. </com-attachment>
  260. </div>
  261. <div>
  262. <com-image mode="aspectFill" :src="scope.row.pic_url">
  263. </div>
  264. </div>
  265. </template>
  266. </el-table-column>
  267. <el-table-column
  268. label="权益内容" width="600">
  269. <template slot-scope="scope">
  270. <el-input type="textarea"
  271. v-model="scope.row.content"
  272. placeholder="请输入内容">
  273. </el-input>
  274. </template>
  275. </el-table-column>
  276. <el-table-column
  277. label="操作">
  278. <template slot-scope="scope">
  279. <el-button size="small" @click="destroyRigths(scope.$index)" type="text" circle>
  280. 删除
  281. </el-button>
  282. </template>
  283. </el-table-column>
  284. </el-table>
  285. <el-button type="text" @click="addBenefits">
  286. <i class="el-icon-plus" style="font-weight: bolder;margin-left: 5px;"></i>
  287. <span style="color: #353535;font-size: 14px">新增权益</span>
  288. </el-button>
  289. </el-form-item>
  290. <el-form-item label="会员有效期设置" prop="is_auto_upgrade" :label-width="formLabelWidth">
  291. <el-switch v-model="ruleForm.is_open_expired" :active-value="1" :inactive-value="0" active-text="开启"
  292. inactive-text="关闭">
  293. </el-switch>
  294. </el-form-item>
  295. <el-form-item :label-width="formLabelWidth" prop="expired_day">
  296. <template slot='label'>
  297. <span>有效期时间</span>
  298. </template>
  299. <el-input placeholder="请输入有效期时间" min="0" type="number" v-model="ruleForm.expired_day"
  300. auto-complete="off" style="width: 300px;">
  301. <template slot="append">天</template>
  302. </el-input>
  303. </el-form-item>
  304. <el-form-item :label-width="formLabelWidth" prop="member_price_is_show">
  305. <template slot='label'>
  306. <span>下级会员价展示</span>
  307. <el-tooltip effect="dark" content="开关开启以后对应该等级的用户商品详情展示下级会员价格"
  308. placement="top">
  309. <i class="el-icon-info"></i>
  310. </el-tooltip>
  311. </template>
  312. <el-switch v-model="ruleForm.member_price_is_show" :active-value="1" :inactive-value="0" active-text="开启"
  313. inactive-text="关闭">
  314. </el-switch>
  315. </el-form-item>
  316. <el-form-item label-width="160px" prop="is_specified_level">
  317. <template slot='label'>
  318. <span>指定等级会员价展示</span>
  319. <el-tooltip effect="dark" content="开启以后勾选了的等级该等级的用户才可以看到勾选的会员价"
  320. placement="top">
  321. <i class="el-icon-info"></i>
  322. </el-tooltip>
  323. </template>
  324. <el-switch v-model="ruleForm.is_specified_level" :active-value="1" :inactive-value="0" active-text="开启"
  325. inactive-text="关闭">
  326. </el-switch>
  327. </el-form-item>
  328. <el-form-item :label-width="formLabelWidth" v-if="ruleForm.is_specified_level == 1">
  329. <template>
  330. <el-checkbox-group v-model="ruleForm.specified_level">
  331. <el-checkbox :label="item.level" v-for="item in level_options" :key="item.level">{{item.name}}</el-checkbox>
  332. </el-checkbox-group>
  333. </template>
  334. </el-form-item>
  335. </el-form>
  336. <div slot="footer" class="dialog-footer">
  337. <el-button type="primary" @click="postAdd('ruleForm')">确 定</el-button>
  338. </div>
  339. </div>
  340. </el-card>
  341. </div>
  342. <script>
  343. new Vue({
  344. el: '#app',
  345. data() {
  346. return {
  347. origin_level:0,
  348. tableData: [],
  349. options: [],//会员等级列表
  350. dialogFormVisible_edit: false,
  351. rules: {
  352. name: [{
  353. required: true,
  354. message: '请输入会员名称',
  355. trigger: 'blur'},
  356. {
  357. validator: (rule, value, callback) => {
  358. if(value.length>65){
  359. callback('1~65个字符');
  360. }
  361. callback();
  362. }
  363. }
  364. ],
  365. discount: [
  366. {
  367. validator: (rule, value, callback) => {
  368. if(value>10||value<0.1){
  369. callback('0.1~10之间的数字');
  370. }
  371. callback();
  372. }
  373. }
  374. ],
  375. level: [{
  376. required: true,
  377. message: '请选择会员等级',
  378. trigger: 'blur'
  379. },
  380. ],
  381. },
  382. level_name: '',
  383. ruleForm: {
  384. id: '',
  385. name: '',
  386. level: '',
  387. status: '1',
  388. pic_url: '',
  389. is_auto_upgrade: 1,
  390. discount: 10,
  391. upgrade_type_condition: 1,
  392. condition_type: 1,
  393. upgrade_type_goods: 1,
  394. goods_type: 1,
  395. buy_goods_type: 1,
  396. buy_cate_type: 1,
  397. goods_ids: [],
  398. goods_list: [],
  399. store_upgrade_type_goods: 1,
  400. store_goods_type: 1,
  401. store_buy_goods_type: 1,
  402. store_goods_ids: [],
  403. store_goods_list: [],
  404. benefits: [],
  405. checked_condition_keys: [],
  406. checked_condition_values:<?= $key_arr?>,
  407. cate_ids :[],
  408. is_open_expired:0,
  409. expired_day:0,
  410. member_price_is_show:0,
  411. enable_goods_protocol: 0,
  412. is_specified_level: 0,
  413. specified_level: [],
  414. is_custom_condition_num: 0,
  415. },
  416. good_cate_list :[],
  417. options_list:<?= $source_list ?>,
  418. checkbox_list: <?= $checkbox_list ?>,
  419. formLabelWidth: '150px',
  420. level_options: [],
  421. is_set_condition: false,
  422. is_show_condition_num: true,
  423. }
  424. },
  425. created() {
  426. this.getList();
  427. },
  428. methods: {
  429. postAdd(formName) {
  430. console.log(11,this.ruleForm);
  431. this.$refs[formName].validate((valid) => {
  432. if (valid) {
  433. this.$request({
  434. method: "post",
  435. params: {
  436. r: 'mall/user-level/edit',
  437. },
  438. data: this.ruleForm
  439. }).then(e => {
  440. if (e.data.code == 0) {
  441. this.$message({
  442. message: e.data.msg,
  443. type: 'success'
  444. });
  445. navigateTo("/index.php?r=mall/user-level/index")
  446. } else {
  447. this.$message.error(e.data.msg);
  448. }
  449. }).catch(e => {
  450. });
  451. }
  452. });
  453. },
  454. getList() {
  455. this.$request({
  456. params: {
  457. r: 'mall/user-level/edit',
  458. id: getQuery('id')
  459. },
  460. }).then(e => {
  461. if (e.data.code == 0) {
  462. if(!isEmpty(e.data.data.checked_condition_values)){
  463. Object.assign(this.ruleForm, e.data.data);
  464. }else{
  465. let checked_condition_values = this.ruleForm.checked_condition_values
  466. Object.assign(this.ruleForm, e.data.data);
  467. this.ruleForm.checked_condition_values = checked_condition_values
  468. }
  469. if(this.ruleForm.good_cate_list) this.ruleForm.good_cate_list = '';
  470. this.origin_level =this.ruleForm.level;
  471. this.good_cate_list = e.data.data.good_cate_list;
  472. this.ruleForm.status=this.ruleForm.status.toString();
  473. this.options = e.data.data.level_list;
  474. this.level_options = e.data.data.user_level_list
  475. if (Array.isArray(this.ruleForm.goods_list)) {
  476. for (const goodsItem of this.ruleForm.goods_list) {
  477. goodsItem.condition_num = goodsItem.condition_num || 1
  478. }
  479. }
  480. } else {
  481. this.$message.error(e.data.msg);
  482. }
  483. }).catch(e => {
  484. });
  485. },
  486. picUrl(e) {
  487. if (e.length) {
  488. this.ruleForm.pic_url = e[0].url;
  489. this.$refs.ruleForm.validateField('pic_url');
  490. }
  491. },
  492. goodsSelect(param) {
  493. for (let j in param) {
  494. let item = param[j];
  495. console.log(item);
  496. if (this.ruleForm.goods_ids&&this.ruleForm.goods_ids.length >= 99) {
  497. this.$message.error('指定商品不能大于99个');
  498. return;
  499. }
  500. let flag = true;
  501. for (let i in this.ruleForm.goods_ids) {
  502. if (this.ruleForm.goods_ids[i] == item.id) {
  503. flag = false;
  504. break;
  505. }
  506. }
  507. if (flag) {
  508. this.ruleForm.goods_ids.push(item.id);
  509. this.ruleForm.goods_list.push({
  510. id: item.id,
  511. condition_num: 1,
  512. name: item.goods_name,
  513. cover_pic: item.cover_pic,
  514. });
  515. }
  516. }
  517. },
  518. storeGoodsSelect(param) {
  519. if(!this.ruleForm.store_goods_ids){
  520. this.ruleForm.store_goods_ids = [];
  521. this.ruleForm.store_goods_list = [];
  522. }
  523. for (let j in param) {
  524. let item = param[j];
  525. console.log(item);
  526. if (this.ruleForm.store_goods_ids.length >= 20) {
  527. this.$message.error('指定门店商品不能大于20个');
  528. return;
  529. }
  530. let flag = true;
  531. for (let i in this.ruleForm.store_goods_ids) {
  532. if (this.ruleForm.store_goods_ids[i] == item.id) {
  533. flag = false;
  534. break;
  535. }
  536. }
  537. if (flag) {
  538. this.ruleForm.store_goods_ids.push(item.id);
  539. this.ruleForm.store_goods_list.push({
  540. id: item.id,
  541. name: item.goods_name,
  542. cover_pic: item.cover_pic,
  543. });
  544. }
  545. }
  546. },
  547. deleteGoods(index) {
  548. this.ruleForm.goods_list.splice(index, 1);
  549. this.ruleForm.goods_ids.splice(index, 1);
  550. },
  551. deleteStoreGoods(index) {
  552. this.ruleForm.store_goods_list.splice(index, 1);
  553. this.ruleForm.store_goods_ids.splice(index, 1);
  554. },
  555. // 添加权益
  556. addBenefits() {
  557. this.ruleForm.benefits.push({
  558. id: 0,
  559. title: '',
  560. pic_url: '',
  561. content: '',
  562. })
  563. },
  564. // 删除权益
  565. destroyRigths(index) {
  566. this.ruleForm.benefits.splice(index, 1);
  567. },
  568. benefitsPicUrl(e, params) {
  569. if (e.length) {
  570. params.pic_url = e[0].url;
  571. }
  572. },
  573. //跳转升级界面
  574. setCondition() {
  575. navigateTo({
  576. r: 'mall/user-level/condition-set',
  577. });
  578. },
  579. clickSelectCloudStockConditionGoods(){
  580. this.$refs.csgoods.$el.click()
  581. },
  582. conditionCloudStockGoodsSelect(param) {
  583. let ckey;
  584. this.ruleForm.checked_condition_values.forEach(function(item, index){
  585. if(item.key==68)
  586. {
  587. ckey=index;
  588. }
  589. })
  590. let gval=this.ruleForm.checked_condition_values[ckey].value.team_goods;
  591. let garr=[];
  592. if(gval && gval.length>0)
  593. {
  594. garr=gval.split(",")
  595. }
  596. for (let j in param) {
  597. let item = param[j];
  598. let isHave=false;
  599. garr.forEach(element => {
  600. if(element==param[j].id)
  601. {
  602. isHave=true;
  603. }
  604. });
  605. if(!isHave)
  606. {
  607. garr.push(param[j].id);
  608. }
  609. }
  610. gval=garr.join(',');
  611. this.ruleForm.checked_condition_values[ckey].value.team_goods=gval;
  612. console.log(this.ruleForm.checked_condition_values[ckey]);
  613. },
  614. clickSelectConditionGoods() {
  615. this.$refs.cgoods.$el.click()
  616. },
  617. conditionGoodsSelect(param) {
  618. let ckey;
  619. this.ruleForm.checked_condition_values.forEach(function(item, index){
  620. if(item.key==91)
  621. {
  622. ckey=index;
  623. }
  624. })
  625. let gval=this.ruleForm.checked_condition_values[ckey].value.goods_ids;
  626. let garr=[];
  627. if(gval && gval.length>0)
  628. {
  629. garr=gval.split(",")
  630. }
  631. for (let j in param) {
  632. let item = param[j];
  633. let isHave=false;
  634. garr.forEach(element => {
  635. if(element==param[j].id)
  636. {
  637. isHave=true;
  638. }
  639. });
  640. if(!isHave)
  641. {
  642. garr.push(param[j].id);
  643. }
  644. }
  645. gval=garr.join(',');
  646. this.ruleForm.checked_condition_values[ckey].value.goods_ids=gval;
  647. },
  648. },
  649. });
  650. </script>