contactList.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <view class="mainBox">
  3. <u-list-item v-for="(item, index) in tableList" :key="index" style="position: relative;">
  4. <myCard @setFree="setFree(item)" @addApply="addApply(item)" @assignModelShow="assignModelShow(item)"
  5. @del="del(item)" :item="item" :index="index+1" :btnList="btnList" :columns="columns"> </myCard>
  6. </u-list-item>
  7. <view style='margin-top: 20vh;' v-if="tableList.length==0">
  8. <u-empty iconSize='150' textSize='32' text='暂无数据'>
  9. </u-empty>
  10. </view>
  11. <u-modal :show="modalShow" @cancel="modalShow=false" :showCancelButton="true" :closeOnClickOverlay="true"
  12. @confirm="assign" :title="'指派'">
  13. <view>
  14. <view>
  15. <u--input placeholder="分管部门" @click.native="showPicker" v-model="addForm.fgDeptName"></u--input>
  16. </view>
  17. <view>
  18. <uni-data-picker v-model="addForm.salesmanId" placeholder="请选择" :localdata="userList"
  19. @change="industryOnchange">
  20. </uni-data-picker>
  21. </view>
  22. </view>
  23. </u-modal>
  24. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" :localdata="listData" valueKey="id"
  25. textKey="name" childrenKey="children" />
  26. <u-toast ref="uToast"></u-toast>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. contactPage,
  32. contactDelete,
  33. free,
  34. assign,
  35. apply
  36. } from '@/api/saleManage/contact/index.js'
  37. import {
  38. listOrganizations,
  39. getUserPage
  40. } from '@/api/myTicket/index.js'
  41. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  42. import myCard from '../components/myCard.vue'
  43. export default {
  44. components: {
  45. baTreePicker,
  46. myCard
  47. },
  48. props: {
  49. btnList: {
  50. default: () => []
  51. }
  52. },
  53. data() {
  54. return {
  55. tableList: [],
  56. page: 1,
  57. size: 10,
  58. isEnd: false,
  59. modalShow: false,
  60. current: {},
  61. userList: [],
  62. listData: [],
  63. addForm: {
  64. contactIds: '',
  65. contactNames: '',
  66. fgDeptId: '',
  67. fgDeptName: '',
  68. salesmanId: '',
  69. salesmanName: ''
  70. },
  71. columns: [
  72. [{
  73. label: '名称:',
  74. prop: 'name',
  75. type: 'title',
  76. className: 'perce100',
  77. }],
  78. [{
  79. label: '编码:',
  80. prop: 'code'
  81. }, {
  82. label: '代号:',
  83. prop: 'serialNo'
  84. }],
  85. [{
  86. label: '联系人:',
  87. prop: 'name'
  88. }, {
  89. label: '联系人电话:',
  90. prop: 'linkPhone'
  91. }],
  92. [{
  93. label: '是否指派:',
  94. prop: 'assignStatus',
  95. formatter: (row) => {
  96. return (row.assignStatus == 1 ? '是' : '否') || ''
  97. }
  98. }, {
  99. label: '销售员:',
  100. prop: 'salesmanName'
  101. }],
  102. [{
  103. label: '详细地址:',
  104. prop: 'addressName',
  105. className: 'perce100',
  106. formatter: (row) => {
  107. return (row.addressName || '') + row.address || ''
  108. }
  109. }],
  110. [{
  111. label: '操作:',
  112. prop: 'action',
  113. type: 'action',
  114. className: 'perce100',
  115. }],
  116. ]
  117. }
  118. },
  119. created() {
  120. this.getDept()
  121. },
  122. methods: {
  123. // 显示选择器
  124. showPicker() {
  125. this.$refs.treePicker._show();
  126. },
  127. confirm(data, name) {
  128. this.addForm.fgDeptName = name
  129. this.addForm.fgDeptId = data[0]
  130. this.addForm.salesmanName = ''
  131. this.addForm.salesmanId = ''
  132. this.getUser(data[0])
  133. },
  134. getDept() {
  135. listOrganizations(1).then(data => {
  136. this.listData = data
  137. })
  138. },
  139. getUser(deptCode) {
  140. getUserPage({
  141. pageNum: 1,
  142. size: -1,
  143. groupId: deptCode
  144. }).then(data => {
  145. this.userList = data.list.map(item => {
  146. item.text = item.name
  147. item.value = item.id
  148. return item
  149. })
  150. })
  151. },
  152. industryOnchange(obj) {
  153. this.addForm.salesmanName = obj.detail.value[0].text
  154. },
  155. del(row) {
  156. contactDelete([row.id]).then(res => {
  157. this.isEnd = false
  158. this.page = 1
  159. this.$refs.uToast.show({
  160. type: "success",
  161. message: "操作成功",
  162. })
  163. this.getList(this.where)
  164. })
  165. },
  166. //释放
  167. setFree(row) {
  168. free({
  169. contactIds: row.id,
  170. contactNames: row.name
  171. }).then((res) => {
  172. this.isEnd = false
  173. this.page = 1
  174. this.$refs.uToast.show({
  175. type: "success",
  176. message: "操作成功",
  177. })
  178. this.getList(this.where)
  179. });
  180. },
  181. assignModelShow(row) {
  182. this.current = row
  183. this.modalShow = true
  184. },
  185. assign() {
  186. if (!this.addForm.fgDeptId) {
  187. console.log(this.$refs)
  188. this.$refs.uToast.show({
  189. type: "error",
  190. message: "请选择分管部门",
  191. position: 'top'
  192. })
  193. return
  194. }
  195. if (!this.addForm.salesmanId) {
  196. this.$refs.uToast.show({
  197. type: "error",
  198. message: "请选择业务员",
  199. position: 'top'
  200. })
  201. return
  202. }
  203. this.addForm.contactIds = this.current.id,
  204. this.addForm.contactNames = this.current.name
  205. assign(this.addForm)
  206. .then((res) => {
  207. this.modalShow = false
  208. this.isEnd = false
  209. this.page = 1
  210. this.$refs.uToast.show({
  211. type: "success",
  212. message: "操作成功",
  213. })
  214. this.getList(this.where)
  215. })
  216. },
  217. doSearch(where) {
  218. this.page = 1
  219. this.isEnd = false
  220. this.getList(where)
  221. },
  222. //申请
  223. addApply(row) {
  224. apply({
  225. contactIds: row.id,
  226. contactNames: row.name
  227. }).then((res) => {
  228. this.isEnd = false
  229. this.page = 1
  230. this.$refs.uToast.show({
  231. type: "success",
  232. message: "操作成功",
  233. })
  234. this.getList(this.where)
  235. });
  236. },
  237. //获取列表信息
  238. getList(where) {
  239. this.where = where
  240. if (this.isEnd) {
  241. return
  242. }
  243. uni.showLoading({
  244. title: '加载中'
  245. })
  246. let data = {
  247. pageNum: this.page,
  248. size: this.size,
  249. ...where
  250. }
  251. contactPage(data).then(res => {
  252. if (this.page === 1) {
  253. this.tableList = res.list
  254. } else {
  255. this.tableList.push(...res.list)
  256. }
  257. this.page += 1
  258. this.isEnd = this.tableList.length >= res.count
  259. }).then(() => {
  260. uni.hideLoading()
  261. })
  262. },
  263. }
  264. }
  265. </script>
  266. <style lang="scss" scoped>
  267. </style>