openSea.vue 13 KB

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