addGroup.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view>
  3. <view class="tits">分组名称</view>
  4. <view class="ipt-box"><input v-model="lableTitle" maxlength="20" placeholder="请输入分组名称" placeholder-class="placeholder" class="ipt" /></view>
  5. <view class="btns dflex">
  6. <view class="delete" v-if="!isAdd" @click="deleteLabel()">删除分组</view>
  7. <view class="btn flex" @click="submitLabel()">保存</view>
  8. </view>
  9. <view class="ceng" v-if="isLabel" @click="hideLabel()"></view>
  10. </view>
  11. </template>
  12. <script>
  13. const app = getApp();
  14. const req = require('../../utils/request.js');
  15. const api = require('../../utils/api.js');
  16. export default {
  17. data() {
  18. return {
  19. isShow: false,
  20. lableTitle: '',
  21. isAdd: false,
  22. groupId: '',
  23. title: '',
  24. };
  25. },
  26. onLoad(opt) {
  27. this.isAdd = opt.isAdd;
  28. this.groupId = opt.groupId;
  29. this.lableTitle = opt.title;
  30. uni.setNavigationBarTitle({
  31. title: this.groupId ? '编辑分组' : '新增分组'
  32. });
  33. },
  34. methods: {
  35. jumpUrl(url) {
  36. uni.navigateTo({
  37. url: url
  38. });
  39. },
  40. deleteLabel() {
  41. console.log('deleteLabel数据>>>>>>>>>');
  42. this.$showModal({
  43. title: '提示',
  44. content: '确定要删除该分组吗'
  45. })
  46. .then(res => {
  47. this.deleteLabelRequest();
  48. })
  49. .catch(err => {
  50. });
  51. },
  52. deleteLabelRequest() {
  53. req.postRequest(
  54. '/api/v3/visiting/card/group/delete',
  55. { id: this.groupId },
  56. json => {
  57. req.msg('删除成功');
  58. setTimeout(() => {
  59. uni.navigateBack();
  60. }, 1500);
  61. },
  62. true
  63. );
  64. },
  65. submitLabel() {
  66. if (!this.lableTitle) {
  67. return req.msg('请输入分组名称');
  68. }
  69. // if (this.customersCkeckList.length == 0) {
  70. // return req.msg('请先添加客户');
  71. // }
  72. let dataP = { groupName: this.lableTitle };
  73. if (this.groupId) {
  74. dataP.id = this.groupId;
  75. }
  76. dataP.userId = req.getStorage('userInfo').id;
  77. console.log('数据参数>>>>>>>>>>>', dataP);
  78. req.postRequest('/api/v3/visiting/card/group/saveOrUpdate',dataP, json => {
  79. req.msg('保存成功');
  80. setTimeout(() => {
  81. uni.navigateBack();
  82. }, 1500);
  83. });
  84. }
  85. }
  86. };
  87. </script>
  88. <style>
  89. @import './addGroup.css';
  90. </style>