openSea.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <!--
  2. * @Author: wanglj 471442253@qq.com
  3. * @Date: 2022-12-15 15:38:21
  4. * @LastEditors: wanglj
  5. * @LastEditTime: 2022-12-28 16:10:14
  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-input v-model="queryForm.custIndustry" placeholder="客户行业" />
  20. </el-col>
  21. <el-col :span="4">
  22. <el-input v-model="queryForm.custLevel" placeholder="客户级别" />
  23. </el-col>
  24. <el-col :span="8">
  25. <el-button icon="el-icon-plus" type="primary" @click="fetchData">查询</el-button>
  26. <el-button icon="el-icon-refresh-right" @click="reset">重置</el-button>
  27. </el-col>
  28. </el-row>
  29. <vab-query-form>
  30. <vab-query-form-left-panel :span="12">
  31. <el-button icon="el-icon-plus" type="primary" @click="$refs.edit.init()">新建</el-button>
  32. <el-button icon="el-icon-plus" type="primary" @click="$refs.allocate.visible = true">分配</el-button>
  33. <el-button icon="el-icon-plus" type="primary" @click="handleReceive">领取</el-button>
  34. </vab-query-form-left-panel>
  35. <vab-query-form-right-panel :span="12">
  36. <el-button icon="el-icon-download" />
  37. <el-button icon="el-icon-setting" />
  38. </vab-query-form-right-panel>
  39. </vab-query-form>
  40. <el-table
  41. v-loading="listLoading"
  42. border
  43. :data="list"
  44. height="calc(100vh - 340px)"
  45. @selection-change="setSelectRows">
  46. <el-table-column align="center" show-overflow-tooltip type="selection" />
  47. <el-table-column align="center" label="客户编码" prop="custCode" />
  48. <el-table-column align="center" label="客户名称" prop="custName" />
  49. <el-table-column align="center" label="助记名" prop="abbrName" />
  50. <el-table-column align="center" label="所在地区" prop="custLocation" />
  51. <el-table-column align="center" label="客户行业" prop="custIndustry" />
  52. <el-table-column align="center" label="客户级别" prop="custLevel" />
  53. <el-table-column align="center" label="客户状态" prop="custStatus">
  54. <template slot-scope="scope">
  55. {{ scope.row.custStatus == 10 ? '正常' : '异常' }}
  56. </template>
  57. </el-table-column>
  58. <el-table-column align="center" label="最后跟进时间" prop="followUpDate" />
  59. <el-table-column align="center" label="创建人" prop="createdName" />
  60. <el-table-column align="center" label="创建时间" prop="createdTime" />
  61. <el-table-column align="center" label="操作">
  62. <template slot-scope="scope">
  63. <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
  64. <el-button type="text" @click="handleDetail(scope.row)">详情</el-button>
  65. <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <el-pagination
  70. background
  71. :current-page="queryForm.pageNum"
  72. :layout="layout"
  73. :page-size="queryForm.pageSize"
  74. :total="total"
  75. @current-change="handleCurrentChange"
  76. @size-change="handleSizeChange" />
  77. <!-- 新增编辑客户弹窗 -->
  78. <Edit ref="edit" @createContact="createContact" @customerSave="customerSave" />
  79. <!-- 新建联系人弹窗 -->
  80. <Contact ref="contact" />
  81. <!-- 分配客户 -->
  82. <Allocate ref="allocate" />
  83. </div>
  84. </template>
  85. <script>
  86. import to from 'await-to-js'
  87. import api from '@/api/customer'
  88. import Contact from './components/Contact'
  89. import Edit from './components/Edit'
  90. import Allocate from './components/Allocate'
  91. export default {
  92. name: 'OpenSea',
  93. components: {
  94. Contact,
  95. Edit,
  96. Allocate,
  97. },
  98. data() {
  99. return {
  100. listLoading: false,
  101. layout: 'total, sizes, prev, pager, next, jumper',
  102. list: [],
  103. total: 0,
  104. queryForm: {
  105. pageNum: 1,
  106. pageSize: 10,
  107. custCode: '', // 客户编码
  108. custName: '', //客户名称
  109. custIndustry: '', // 客户行业 ()
  110. custLevel: '', //客户级别
  111. },
  112. selectRows: [],
  113. }
  114. },
  115. mounted() {
  116. this.fetchData()
  117. this.getOptions()
  118. },
  119. methods: {
  120. getOptions() {
  121. Promise.all([api.getProvinceInfo()])
  122. .then(([province]) => {
  123. this.provinceOptions = province.data.list || []
  124. })
  125. .catch((err) => console.log(err))
  126. },
  127. async fetchData() {
  128. this.listLoading = true
  129. const params = { ...this.queryForm }
  130. const [err, res] = await to(api.getPublicList(params))
  131. if (err) return (this.listLoading = false)
  132. this.list = res.data.list || []
  133. this.total = res.data.total
  134. this.listLoading = false
  135. },
  136. reset() {
  137. this.queryForm = {
  138. pageNum: 1,
  139. pageSize: 10,
  140. custCode: '', // 客户编码
  141. custName: '', //客户名称
  142. custIndustry: '', // 客户行业 ()
  143. custLevel: '', //客户级别
  144. }
  145. this.fetchData()
  146. },
  147. handleSizeChange(val) {
  148. this.queryForm.pageSize = val
  149. this.fetchData()
  150. },
  151. handleCurrentChange(val) {
  152. this.queryForm.pageNum = val
  153. this.fetchData()
  154. },
  155. setSelectRows(val) {
  156. this.selectRows = val
  157. },
  158. // 客户编辑
  159. async handleEdit(row) {
  160. this.$refs.edit.init([row.id])
  161. },
  162. // 客户详情
  163. handleDetail(row) {
  164. this.$router.push({
  165. path: '/customer/detail',
  166. query: {
  167. id: row.id,
  168. },
  169. })
  170. },
  171. // 客户删除
  172. handleDelete(row) {
  173. this.$confirm('确认删除?', '提示', {
  174. confirmButtonText: '确定',
  175. cancelButtonText: '取消',
  176. type: 'warning',
  177. })
  178. .then(async () => {
  179. const [err, res] = await to(api.deleteCustomer({ Id: row.id }))
  180. if (err) return
  181. if (res.code == 200) {
  182. this.$message({
  183. type: 'success',
  184. message: '删除成功!',
  185. })
  186. this.fetchData()
  187. }
  188. })
  189. .catch(() => {})
  190. },
  191. // 联系人弹窗
  192. createContact(res) {
  193. this.$refs.contact.contactForm.custId = res.id
  194. this.$refs.contact.contactForm.custName = res.name
  195. this.$refs.contact.contactVisible = true
  196. },
  197. customerSave() {
  198. this.fetchData()
  199. },
  200. handleClose(form) {
  201. this.$refs[form].resetFields()
  202. },
  203. // 领取
  204. handleReceive() {
  205. if (!this.selectRows.length) return this.$message.warning('请选择客户')
  206. const arr = this.selectRows.map((item) => item.id)
  207. this.$confirm('确认领取客户?', '提示', {
  208. confirmButtonText: '确定',
  209. cancelButtonText: '取消',
  210. type: 'warning',
  211. })
  212. .then(async () => {
  213. const [err, res] = await to(api.receiveCustomer({ ids: arr.join() }))
  214. if (err) return
  215. if (res.code == 200) {
  216. this.$message({
  217. type: 'success',
  218. message: '领取成功!',
  219. })
  220. }
  221. })
  222. .then(async () => {
  223. const [err, res] = await to(api.receiveCustomer({ ids: arr, salesId: 1 }))
  224. if (err) return
  225. if (res.code == 200) {
  226. this.$message({
  227. type: 'success',
  228. message: '领取成功!',
  229. })
  230. }
  231. })
  232. .catch(() => {})
  233. },
  234. },
  235. }
  236. </script>
  237. <style lang="scss" scoped>
  238. $base: '.open-sea';
  239. </style>