contactList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="after_sales">
  3. <view class="bth_oper">
  4. <view class="btn add" @click="goContact('add')">添加</view>
  5. <view class="btn del" @click="batchDelete">删除</view>
  6. <text class="reserve">请至少保留一条联系人数据</text>
  7. </view>
  8. <u-list class="listContent">
  9. <checkbox-group v-for="(item, index) in contactList" :key="index" @change="e => selectVal(e, item, index)">
  10. <label>
  11. <view class="listBox">
  12. <view class="listBox-sel">
  13. <checkbox :value="item.id" color="#fff" :disabled="item.disabled" :checked="item.checked" />
  14. </view>
  15. <view class="listBox-con">
  16. <view class="listBox-bottom">
  17. <view>姓名:{{ item.contactName }}</view>
  18. <view>手机:{{ item.contactPhone }}</view>
  19. <view>电话:{{ item.telephone }}</view>
  20. <view>微信号:{{ item.wechat }}</view>
  21. <view>邮箱:{{ item.email }}</view>
  22. <view>部门:{{ item.deptName }}</view>
  23. <view>职务:{{ item.post }}</view>
  24. <view>备注:{{ item.remark }}</view>
  25. <view class="action">
  26. <text class="text">
  27. 操作:
  28. </text>
  29. <u-button @click="goContact('edit',index,item)" :plain="true" :hairline="true"
  30. size='mini' type="default" text="编辑"></u-button>
  31. <u-button @click="del" :plain="true" :hairline="true" size='mini' type="default"
  32. class="delete" text="删除"></u-button>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </label>
  38. </checkbox-group>
  39. <u-empty class="noDate" style="margin-top: 20vh" v-if="!contactList.length"></u-empty>
  40. </u-list>
  41. </view>
  42. </template>
  43. <script>
  44. import myCard from '@/pages/saleManage/components/myCard.vue'
  45. export default {
  46. components: {
  47. myCard
  48. },
  49. props: {
  50. itemList: {
  51. type: Array,
  52. default: () => []
  53. }
  54. },
  55. watch: {
  56. itemList: {
  57. handler(newVal) {
  58. let list = JSON.parse(JSON.stringify(newVal));
  59. this.contactList = list
  60. },
  61. deep: true,
  62. immediate: true
  63. }
  64. },
  65. computed: {},
  66. data() {
  67. return {
  68. contactList: []
  69. }
  70. },
  71. onLoad({}) {},
  72. created() {
  73. uni.$off('updateContactList')
  74. uni.$on('updateContactList', ({
  75. type,
  76. data,
  77. index
  78. }) => {
  79. console.log(data, 'data');
  80. if (type == 'add') {
  81. this.contactList.push(data);
  82. } else {
  83. this.$set(this.contactList, index, data);
  84. }
  85. })
  86. },
  87. methods: {
  88. // 勾选数据
  89. selectVal(e, val, index) {
  90. this.$set(this.contactList[index], 'checked', !this.contactList[index].checked)
  91. },
  92. // 删除联系人
  93. del(index) {
  94. uni.showModal({
  95. title: '确认删除',
  96. content: '确定要删除这条联系人数据吗?',
  97. confirmText: '删除',
  98. confirmColor: '#FF4D4F',
  99. success: (res) => {
  100. if (res.confirm) {
  101. this.contactList.splice(index, 1);
  102. } else if (res.cancel) {
  103. // 用户点击了取消按钮
  104. console.log('用户取消删除');
  105. }
  106. }
  107. });
  108. },
  109. // 批量删除
  110. batchDelete() {
  111. uni.showModal({
  112. title: '确认删除',
  113. content: '确定要删除所选联系人数据吗?',
  114. confirmText: '删除',
  115. confirmColor: '#FF4D4F',
  116. success: (res) => {
  117. if (res.confirm) {
  118. this.contactList = this.contactList.filter(item=> !item.checked);
  119. } else if (res.cancel) {
  120. // 用户点击了取消按钮
  121. console.log('用户取消删除');
  122. }
  123. }
  124. });
  125. },
  126. // 现在只针对做 一 对 多 的 故障数据
  127. goContact(type, index, obj) {
  128. let data = obj ? JSON.stringify(obj) : '';
  129. uni.navigateTo({
  130. url: `/pages/salesServiceManagement/demandList/components/contactAdd?type=${type}&index=${index}&data=${data}`
  131. })
  132. },
  133. addFault() {
  134. },
  135. getTabData() {
  136. return this.contactList || []
  137. }
  138. },
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. @import './invoice.scss';
  143. .bth_oper {
  144. display: flex;
  145. align-items: center;
  146. margin-top: 16rpx;
  147. border-bottom: 1px solid #e5e5e5;
  148. padding-bottom: 16rpx;
  149. .btn {
  150. width: 80rpx;
  151. height: 48rpx;
  152. line-height: 48rpx;
  153. text-align: center;
  154. background: #1890ff;
  155. font-size: 26rpx;
  156. color: #ffffff;
  157. border-radius: 8rpx;
  158. }
  159. .del {
  160. background: #ff4d4f;
  161. }
  162. .reserve {
  163. color: #e6a23c;
  164. font-size: 26rpx;
  165. margin-left: 18rpx;
  166. }
  167. }
  168. .action {
  169. display: flex;
  170. line-height: 22px;
  171. .text {
  172. margin-right: 12rpx;
  173. }
  174. /deep/ .u-button {
  175. width: 100rpx;
  176. font-size: 26rpx;
  177. margin-left: 10rpx;
  178. margin-right: 0rpx;
  179. background: #157a2c;
  180. color: #fff !important;
  181. }
  182. }
  183. </style>