contactList.vue 5.6 KB

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