list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <!--
  2. * @Author: wanglj 471442253@qq.com
  3. * @Date: 2022-12-26 16:34:37
  4. * @LastEditors: wanglj
  5. * @LastEditTime: 2023-01-05 13:39:44
  6. * @Description: file content
  7. * @FilePath: \opms_frontend\src\views\customer\list.vue
  8. -->
  9. <template>
  10. <div class="list-container">
  11. <el-tabs v-model="activeName" @tab-click="handleClick">
  12. <el-tab-pane label="全部客户" name="first" />
  13. <el-tab-pane label="我的客户" name="second" />
  14. <el-tab-pane label="下属的客户" name="third" />
  15. </el-tabs>
  16. <el-row :gutter="10" style="margin-bottom: 10px">
  17. <el-col :span="4">
  18. <el-input v-model="queryForm.custCode" placeholder="客户编码" />
  19. </el-col>
  20. <el-col :span="4">
  21. <el-input v-model="queryForm.custName" placeholder="客户名称" />
  22. </el-col>
  23. <el-col :span="4">
  24. <el-select v-model="queryForm.custIndustry" placeholder="客户行业" style="width: 100%">
  25. <el-option v-for="item in industryOptions" :key="item.value" :label="item.value" :value="item.value" />
  26. </el-select>
  27. </el-col>
  28. <el-col :span="4">
  29. <el-select v-model="queryForm.custLevel" placeholder="客户级别" style="width: 100%">
  30. <el-option v-for="item in levelOptions" :key="item.value" :label="item.value" :value="item.value" />
  31. </el-select>
  32. </el-col>
  33. <el-col :span="4">
  34. <el-date-picker
  35. v-model="queryForm.followUpDate"
  36. placeholder="最后跟进时间"
  37. style="width: 100%"
  38. type="date"
  39. value-format="yyyy-MM-dd" />
  40. </el-col>
  41. <el-col :span="4">
  42. <el-button icon="el-icon-plus" type="primary" @click="fetchData">查询</el-button>
  43. <el-button icon="el-icon-refresh-right" @click="reset">重置</el-button>
  44. </el-col>
  45. </el-row>
  46. <vab-query-form>
  47. <vab-query-form-left-panel :span="12">
  48. <el-button icon="el-icon-plus" size="mini" type="primary" @click="$refs.edit.init()">新建</el-button>
  49. <el-button icon="el-icon-plus" size="mini" type="primary" @click="handleShift">转移客户</el-button>
  50. <el-button icon="el-icon-plus" size="mini" type="primary" @click="handleToOpen">移入公海</el-button>
  51. <el-button icon="el-icon-plus" size="mini" type="primary" @click="handleMerge">合并客户</el-button>
  52. </vab-query-form-left-panel>
  53. <vab-query-form-right-panel :span="12">
  54. <el-button icon="el-icon-download" />
  55. <table-tool :check-list.sync="checkList" :columns="columns" />
  56. </vab-query-form-right-panel>
  57. </vab-query-form>
  58. <el-table
  59. v-loading="listLoading"
  60. border
  61. :data="list"
  62. height="calc(100vh - 394px)"
  63. @selection-change="setSelectRows">
  64. <el-table-column align="center" show-overflow-tooltip type="selection" />
  65. <el-table-column align="center" label="客户编码" prop="custCode" />
  66. <el-table-column align="center" label="客户名称" prop="custName" />
  67. <el-table-column align="center" label="助记名" prop="abbrName" />
  68. <el-table-column align="center" label="所在地区" prop="custLocation" />
  69. <el-table-column align="center" label="客户行业" prop="custIndustry" />
  70. <el-table-column align="center" label="客户级别" prop="custLevel" />
  71. <el-table-column align="center" label="客户状态" prop="custStatus">
  72. <template slot-scope="scope">
  73. {{ scope.row.custStatus == 10 ? '正常' : '异常' }}
  74. </template>
  75. </el-table-column>
  76. <el-table-column
  77. v-for="(item, index) in finallyColumns"
  78. :key="index"
  79. align="center"
  80. :label="item.label"
  81. :min-width="item.width"
  82. :prop="item.prop"
  83. show-overflow-tooltip
  84. :sortable="item.sortable">
  85. <template #default="{ row }">
  86. <el-button v-if="item.prop === 'custName'" class="link-button" type="text" @click="handleDetail(row)">
  87. {{ row.custName }}
  88. </el-button>
  89. <span v-else-if="item.prop === 'custStatus'">
  90. {{ row.custStatus == 10 ? '正常' : '异常' }}
  91. </span>
  92. <span v-else>{{ row[item.prop] }}</span>
  93. </template>
  94. </el-table-column>
  95. <el-table-column align="center" label="操作">
  96. <template slot-scope="scope">
  97. <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
  98. <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <el-pagination
  103. background
  104. :current-page="queryForm.pageNum"
  105. :layout="layout"
  106. :page-size="queryForm.pageSize"
  107. :total="total"
  108. @current-change="handleCurrentChange"
  109. @size-change="handleSizeChange" />
  110. <!-- 新增编辑客户弹窗 -->
  111. <Edit ref="edit" @createContact="createContact" @customerSave="fetchData" />
  112. <!-- 新建联系人弹窗 -->
  113. <Contact ref="contact" />
  114. <!-- 转移客户 -->
  115. <Shift ref="shift" @refresh="fetchData" />
  116. <!-- 移入公海 -->
  117. <ToOpen ref="toOpen" @refresh="fetchData" />
  118. <!-- 合并客户 -->
  119. <Merge ref="merge" @refresh="fetchData" />
  120. </div>
  121. </template>
  122. <script>
  123. import to from 'await-to-js'
  124. import api from '@/api/customer'
  125. import Edit from './components/Edit'
  126. import Contact from './components/Contact'
  127. import Shift from './components/Shift'
  128. import ToOpen from './components/ToOpen'
  129. import Merge from './components/Merge'
  130. import TableTool from '@/components/table/TableTool'
  131. export default {
  132. components: {
  133. Edit,
  134. Contact,
  135. Shift,
  136. ToOpen,
  137. Merge,
  138. TableTool,
  139. },
  140. data() {
  141. return {
  142. activeName: 'first',
  143. layout: 'total, sizes, prev, pager, next, jumper',
  144. queryForm: {
  145. custCode: '',
  146. custName: '',
  147. indusTry: '',
  148. pageNum: 1,
  149. pageSize: 10,
  150. },
  151. total: 0,
  152. listLoading: false,
  153. list: [],
  154. selectRows: [],
  155. industryOptions: [], //客户行业
  156. levelOptions: [], //客户级别
  157. // 自定义列表
  158. checkList: [],
  159. columns: [
  160. {
  161. label: '客户编码',
  162. width: '120px',
  163. prop: 'custCode',
  164. sortable: false,
  165. disableCheck: false,
  166. },
  167. {
  168. label: '客户名称',
  169. width: '120px',
  170. prop: 'custName',
  171. sortable: false,
  172. disableCheck: true,
  173. },
  174. {
  175. label: '助记名',
  176. width: 'auto',
  177. prop: 'abbrName',
  178. sortable: false,
  179. disableCheck: false,
  180. },
  181. {
  182. label: '所在地区',
  183. width: 'auto',
  184. prop: 'custLocation',
  185. sortable: false,
  186. disableCheck: false,
  187. },
  188. {
  189. label: '客户行业',
  190. width: 'auto',
  191. prop: 'custIndustry',
  192. sortable: false,
  193. disableCheck: false,
  194. },
  195. {
  196. label: '客户级别',
  197. width: 'auto',
  198. prop: 'custLevel',
  199. sortable: false,
  200. disableCheck: false,
  201. },
  202. {
  203. label: '客户状态',
  204. width: 'auto',
  205. prop: 'custStatus',
  206. sortable: false,
  207. disableCheck: false,
  208. },
  209. {
  210. label: '最后跟进时间',
  211. width: '140px',
  212. prop: 'followUpDate',
  213. sortable: false,
  214. disableCheck: false,
  215. },
  216. {
  217. label: '创建时间',
  218. width: '140px',
  219. prop: 'createdTime',
  220. sortable: false,
  221. disableCheck: false,
  222. },
  223. ],
  224. }
  225. },
  226. computed: {
  227. finallyColumns() {
  228. return this.columns.filter((item) => this.checkList.includes(item.label))
  229. },
  230. },
  231. mounted() {
  232. this.getOptions()
  233. this.fetchData()
  234. },
  235. methods: {
  236. getOptions() {
  237. Promise.all([this.getDicts('CustomerLevel'), this.getDicts('CustomerIndustry')])
  238. .then(([level, industry]) => {
  239. this.levelOptions = level.data.values || []
  240. this.industryOptions = industry.data.values || []
  241. })
  242. .catch((err) => console.log(err))
  243. },
  244. handleClick(tab) {
  245. console.log(tab, 'tab')
  246. this.fetchData()
  247. },
  248. async fetchData() {
  249. this.listLoading = true
  250. const params = { ...this.queryForm }
  251. const [err, res] = await to(api.getList(params))
  252. if (err) return (this.listLoading = false)
  253. this.list = res.data.list || []
  254. this.total = res.data.total
  255. this.listLoading = false
  256. },
  257. reset() {
  258. this.queryForm = {
  259. pageNum: 1,
  260. pageSize: 10,
  261. custCode: '', // 客户编码
  262. custName: '', //客户名称
  263. indusTry: '', // 客户行业 ()
  264. }
  265. this.fetchData()
  266. },
  267. // 客户编辑
  268. handleEdit(row) {
  269. this.$refs.edit.init([row.id])
  270. },
  271. // 联系人弹窗
  272. async createContact(res) {
  273. this.$refs.contact.contactForm.custId = res.id
  274. this.$refs.contact.contactForm.custName = res.name
  275. this.$refs.contact.contactVisible = true
  276. },
  277. // 客户详情
  278. handleDetail(row) {
  279. this.$router.push({
  280. path: '/customer/detail',
  281. query: {
  282. id: row.id,
  283. privateCus: 1,
  284. },
  285. })
  286. },
  287. // 客户删除
  288. handleDelete(row) {
  289. this.$confirm('确认删除?', '提示', {
  290. confirmButtonText: '确定',
  291. cancelButtonText: '取消',
  292. type: 'warning',
  293. })
  294. .then(async () => {
  295. const [err, res] = await to(api.deleteCustomer({ Id: row.id }))
  296. if (err) return
  297. if (res.code == 200) {
  298. this.$message({
  299. type: 'success',
  300. message: '删除成功!',
  301. })
  302. }
  303. })
  304. .catch(() => {})
  305. },
  306. handleSizeChange(val) {
  307. this.queryForm.pageSize = val
  308. this.fetchData()
  309. },
  310. handleCurrentChange(val) {
  311. this.queryForm.pageNum = val
  312. this.fetchData()
  313. },
  314. setSelectRows(val) {
  315. this.selectRows = val
  316. },
  317. // 转移客户
  318. handleShift() {
  319. if (!this.selectRows.length) return this.$message.warning('请选择需要转移的客户')
  320. this.$refs.shift.form.Ids = this.selectRows.map((item) => item.id)
  321. this.$refs.shift.visible = true
  322. },
  323. // 移入公海
  324. handleToOpen() {
  325. if (!this.selectRows.length) return this.$message.warning('请选择要移入公海的客户')
  326. this.$refs.toOpen.form.ids = this.selectRows.map((item) => item.id)
  327. this.$refs.toOpen.visible = true
  328. },
  329. async handleMerge() {
  330. if (this.selectRows.length < 2) return this.$message.warning('请选择两个以上客户进行合并')
  331. const ids = this.selectRows.map((item) => item.id)
  332. const [err, res] = await to(api.getDetail({ ids }))
  333. if (err) return
  334. this.$refs.merge.init(res, ids)
  335. },
  336. },
  337. }
  338. </script>
  339. <style lang="scss" scoped>
  340. $base: '.list';
  341. .link-button {
  342. font-size: 14px;
  343. width: 100%;
  344. overflow: hidden;
  345. text-overflow: ellipsis;
  346. white-space: nowrap;
  347. }
  348. </style>