list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <a-card size="small" :bordered="false" class="customerManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="客户名称">
  10. <a-input id="customerManagementList-customerName" v-model.trim="queryParam.customerName" allowClear placeholder="请输入客户名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="联系人">
  15. <a-input id="customerManagementList-contactName" v-model.trim="queryParam.contactName" allowClear placeholder="请输入联系人"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="最后销售时间">
  20. <rangeDate id="customerManagementList-date" ref="rangeSaleDate" @change="dateSaleChange" />
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="客户关系">
  26. <v-select
  27. code="CUSTOMER_RELATION_TYPE"
  28. id="customerManagementList-relationType"
  29. v-model="queryParam.relationType"
  30. allowClear
  31. placeholder="请选择客户关系"
  32. ></v-select>
  33. </a-form-item>
  34. </a-col>
  35. <!-- <a-col :md="6" :sm="24">
  36. <a-form-item label="是否为下级">
  37. <v-select code="FLAG" id="customerManagementList-dealerFlag" v-model="queryParam.dealerFlag" allowClear placeholder="请选择"></v-select>
  38. </a-form-item>
  39. </a-col> -->
  40. <a-col :md="6" :sm="24">
  41. <a-form-item label="客户地址">
  42. <AreaList id="customerManagementList-area" changeOnSelect ref="areaList" @change="areaChange"></AreaList>
  43. </a-form-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-item label="客户类型">
  47. <custType id="customerManagementList-custType" v-model="queryParam.customerTypeSn" allowClear placeholder="请选择客户类型"></custType>
  48. </a-form-item>
  49. </a-col>
  50. <a-col :md="6" :sm="24">
  51. <a-form-item label="启用状态">
  52. <v-select id="customerManagementList-flag" code="ENABLE_FLAG" v-model="queryParam.enabledFlag" allowClear placeholder="请选择启用状态"></v-select>
  53. </a-form-item>
  54. </a-col>
  55. </template>
  56. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  57. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="customerManagementList-refresh">查询</a-button>
  58. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="customerManagementList-reset">重置</a-button>
  59. <a @click="advanced=!advanced" style="margin-left: 5px" id="customerManagementList-advanced">
  60. {{ advanced ? '收起' : '展开' }}
  61. <a-icon :type="advanced ? 'up' : 'down'"/>
  62. </a>
  63. </a-col>
  64. </a-row>
  65. </a-form>
  66. </div>
  67. <!-- 操作按钮 -->
  68. <div class="table-operator">
  69. <a-button v-if="$hasPermissions('B_customer_customerInfo_add')" id="customerManagementList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
  70. </div>
  71. <!-- 列表 -->
  72. <s-table
  73. class="sTable fixPagination"
  74. ref="table"
  75. :style="{ height: tableHeight+68+'px' }"
  76. size="small"
  77. :rowKey="(record) => record.id"
  78. :columns="columns"
  79. :data="loadData"
  80. :scroll="{ y: tableHeight }"
  81. :defaultLoadData="false"
  82. bordered>
  83. <!-- 操作 -->
  84. <template slot="action" slot-scope="text, record">
  85. <a-button
  86. size="small"
  87. v-if="$hasPermissions('B_customer_customerInfo_edit')"
  88. type="link"
  89. class="button-primary"
  90. @click="handleEdit(record)"
  91. :id="'customerManagementList-edit-'+record.id">编辑</a-button>
  92. <a-button
  93. size="small"
  94. v-if="$hasPermissions('B_customer_customerInfo_detail')"
  95. type="link"
  96. class="button-success"
  97. @click="handleDetail(record)"
  98. :id="'customerManagementList-detail-'+record.id">详情</a-button>
  99. <a-button
  100. size="small"
  101. v-if="$hasPermissions('B_customer_customerInfo_edit')"
  102. type="link"
  103. class="button-primary"
  104. @click="mergeCustomer(record)"
  105. :id="'customerManagementList-merge-'+record.id">合并</a-button>
  106. <span v-if="!$hasPermissions('B_customer_customerInfo_edit') && !$hasPermissions('B_customer_customerInfo_detail')">--</span>
  107. </template>
  108. <template slot="enableAction" slot-scope="text, record">
  109. <a-switch
  110. :id="'customerManagementList-switch-'+record.id"
  111. v-if="$hasPermissions('B_customer_customerInfo_enable')"
  112. checkedChildren="启用"
  113. unCheckedChildren="禁用"
  114. v-model="record.enabledFlag"
  115. @change="changeFlagHandle(text, record)"/>
  116. <span v-else :style="{color:(record.enabledFlag==1?'#00aa00':'#999')}"> {{ record.enabledFlag==1? '已启用': '已禁用' }} </span>
  117. </template>
  118. </s-table>
  119. </a-spin>
  120. <!-- 客户详情 -->
  121. <customer-management-detail-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  122. <!-- 合并用户 -->
  123. <merge-customer-modal :openModal="openMergeModal" :params="customerTemp" @close="closeMergeModal" />
  124. </a-card>
  125. </template>
  126. <script>
  127. import { commonMixin } from '@/utils/mixin'
  128. import { custList, custDel, updateEnableStatus } from '@/api/customer'
  129. import AreaList from '@/views/common/areaList.js'
  130. import custType from '@/views/common/custType.js'
  131. import { STable, VSelect } from '@/components'
  132. import rangeDate from '@/views/common/rangeDate.vue'
  133. import customerManagementDetailModal from './detailModal.vue'
  134. import mergeCustomerModal from './mergeCustomerModal.vue'
  135. export default {
  136. name: 'CustomerManagementList',
  137. components: { STable, VSelect, customerManagementDetailModal, rangeDate, AreaList, custType, mergeCustomerModal },
  138. mixins: [commonMixin],
  139. data () {
  140. return {
  141. spinning: false,
  142. advanced: true, // 高级搜索 展开/关闭
  143. tableHeight: 0,
  144. queryParam: { // 查询条件
  145. saleBeginDate: '',
  146. saleEndDate: '',
  147. customerName: undefined, // 客户名称
  148. contactName: '', // 联系人
  149. provinceSn: undefined, // 省
  150. citySn: undefined, // 市
  151. countySn: undefined, // 区
  152. dealerFlag: undefined, // 是否卫星仓客户
  153. customerTypeSn: undefined, // 客户类型
  154. enabledFlag: '1', // 启用状态
  155. relationType: undefined // 客户关系
  156. },
  157. disabled: false, // 查询、重置按钮是否可操作
  158. columns: [
  159. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  160. { title: '客户名称', dataIndex: 'customerName', width: '28%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  161. { title: '联系人', dataIndex: 'contactName', width: '7%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  162. { title: '联系电话', dataIndex: 'contactTel', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  163. { title: '联系手机', dataIndex: 'contactMobile', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  164. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  165. { title: '最后销售时间', dataIndex: 'lastSaleTime', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  166. { title: '客户关系', dataIndex: 'relationTypeDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  167. // { title: '是否为下级', dataIndex: 'dealerFlagDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  168. { title: '价格类型', dataIndex: 'priceTypeDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '启用状态', scopedSlots: { customRender: 'enableAction' }, width: '8%', align: 'center' },
  170. { title: <div><a-tooltip placement='top' title='注意:客户合并功能中,将以当前客户为对象,合并被选客户。'><a-icon type="question-circle" /></a-tooltip>&nbsp;操作</div>, scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  171. ],
  172. // 加载数据方法 必须为 Promise 对象
  173. loadData: parameter => {
  174. this.disabled = true
  175. this.spinning = true
  176. return custList(Object.assign(parameter, this.queryParam)).then(res => {
  177. let data
  178. if (res.status == 200) {
  179. data = res.data
  180. const no = (data.pageNo - 1) * data.pageSize
  181. for (var i = 0; i < data.list.length; i++) {
  182. data.list[i].no = no + i + 1
  183. data.list[i].enabledFlag = data.list[i].enabledFlag + '' === '1'
  184. }
  185. this.disabled = false
  186. }
  187. this.spinning = false
  188. return data
  189. })
  190. },
  191. addrProvinceList: [], // 省下拉
  192. addrCityList: [], // 市下拉
  193. addrDistrictList: [], // 区下拉
  194. openModal: false, // 查看客户详情 弹框
  195. itemId: '', // 当前客户id
  196. openMergeModal: false, // 合并用户名称
  197. customerTemp: {}// 临时客户数据
  198. }
  199. },
  200. methods: {
  201. // 时间 change
  202. dateSaleChange (date) {
  203. this.queryParam.saleBeginDate = date[0] ? date[0] : ''
  204. this.queryParam.saleEndDate = date[1] ? date[1] : ''
  205. },
  206. // 地区
  207. areaChange (val) {
  208. this.queryParam.provinceSn = val[0] ? val[0] : undefined
  209. this.queryParam.citySn = val[1] ? val[1] : undefined
  210. this.queryParam.countySn = val[2] ? val[2] : undefined
  211. },
  212. // 重置
  213. resetSearchForm () {
  214. this.$refs.rangeSaleDate.resetDate()
  215. this.queryParam.saleBeginDate = ''
  216. this.queryParam.saleEndDate = ''
  217. this.queryParam.customerName = undefined
  218. this.queryParam.contactName = ''
  219. this.queryParam.provinceSn = undefined
  220. this.queryParam.citySn = undefined
  221. this.queryParam.countySn = undefined
  222. this.queryParam.dealerFlag = undefined
  223. this.queryParam.customerTypeSn = undefined
  224. this.queryParam.relationType = undefined
  225. this.queryParam.enabledFlag = '1'
  226. this.addrCityList = []
  227. this.addrDistrictList = []
  228. if (this.advanced) {
  229. this.$refs.areaList.clearData()
  230. }
  231. this.$refs.table.refresh(true)
  232. },
  233. // 新增/编辑
  234. handleEdit (row) {
  235. if (row) { // 编辑
  236. this.$router.push({ path: `/customerManagement/customerInfo/edit/${row.id}` })
  237. } else { // 新增
  238. this.$router.push({ path: '/customerManagement/customerInfo/add' })
  239. }
  240. },
  241. // 删除
  242. handleDel (row) {
  243. const _this = this
  244. this.$confirm({
  245. title: '提示',
  246. content: '删除后不可恢复,确定要进行删除吗?',
  247. centered: true,
  248. onOk () {
  249. _this.spinning = true
  250. custDel({ id: row.id }).then(res => {
  251. if (res.status == 200) {
  252. _this.$message.success(res.message)
  253. _this.$refs.table.refresh()
  254. _this.spinning = false
  255. } else {
  256. _this.spinning = false
  257. }
  258. })
  259. }
  260. })
  261. },
  262. // 修改状态
  263. changeFlagHandle (text, record) {
  264. const _data = {
  265. id: record.id,
  266. flag: record.enabledFlag ? '1' : '0'
  267. }
  268. this.spinning = true
  269. updateEnableStatus(_data).then(res => {
  270. if (res.status == 200) {
  271. this.$message.success(res.message)
  272. this.$refs.table.refresh()
  273. this.spinning = false
  274. } else {
  275. this.$refs.table.refresh()
  276. this.spinning = false
  277. }
  278. })
  279. },
  280. // 客户信息详情
  281. handleDetail (row) {
  282. this.itemId = row.id
  283. this.openModal = true
  284. },
  285. // 合并客户
  286. mergeCustomer (row) {
  287. this.customerTemp = row
  288. this.openMergeModal = true
  289. },
  290. // 关闭合并客户弹框
  291. closeMergeModal (flag) {
  292. this.customerTemp = ''
  293. this.openMergeModal = false
  294. if (flag) {
  295. this.$refs.table.refresh()
  296. }
  297. },
  298. // 关闭弹框
  299. closeModal () {
  300. this.itemId = ''
  301. this.openModal = false
  302. },
  303. pageInit () {
  304. const _this = this
  305. this.$nextTick(() => { // 页面渲染完成后的回调
  306. _this.setTableH()
  307. })
  308. },
  309. setTableH () {
  310. const tableSearchH = this.$refs.tableSearch.offsetHeight
  311. this.tableHeight = window.innerHeight - tableSearchH - 220
  312. }
  313. },
  314. watch: {
  315. advanced (newValue, oldValue) {
  316. const _this = this
  317. this.$nextTick(() => { // 页面渲染完成后的回调
  318. _this.setTableH()
  319. })
  320. },
  321. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  322. this.setTableH()
  323. }
  324. },
  325. mounted () {
  326. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  327. this.pageInit()
  328. this.resetSearchForm()
  329. }
  330. },
  331. activated () {
  332. // 如果是新页签打开,则重置当前页面
  333. if (this.$store.state.app.isNewTab) {
  334. this.pageInit()
  335. this.resetSearchForm()
  336. }
  337. // 仅刷新列表,不重置页面
  338. if (this.$store.state.app.updateList) {
  339. this.pageInit()
  340. this.$refs.table.refresh()
  341. }
  342. },
  343. beforeRouteEnter (to, from, next) {
  344. next(vm => {})
  345. }
  346. }
  347. </script>