list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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 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 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 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 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">
  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-btn">编辑</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-btn">详情</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-edit-btn">合并</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 v-if="$hasPermissions('B_customer_customerInfo_enable')" checkedChildren="启用" unCheckedChildren="禁用" v-model="record.enabledFlag" @change="changeFlagHandle(text, record)"/>
  110. <span v-else :style="{color:(record.enabledFlag==1?'#00aa00':'#999')}"> {{ record.enabledFlag==1? '已启用': '已禁用' }} </span>
  111. </template>
  112. </s-table>
  113. </a-spin>
  114. <!-- 客户详情 -->
  115. <customer-management-detail-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  116. <!-- 合并用户 -->
  117. <merge-customer-modal :openModal="openMergeModal" :params="customerTemp" @close="closeMergeModal" />
  118. </a-card>
  119. </template>
  120. <script>
  121. import { commonMixin } from '@/utils/mixin'
  122. import { custList, custDel, updateEnableStatus } from '@/api/customer'
  123. import AreaList from '@/views/common/areaList.js'
  124. import custType from '@/views/common/custType.js'
  125. import { STable, VSelect } from '@/components'
  126. import rangeDate from '@/views/common/rangeDate.vue'
  127. import customerManagementDetailModal from './detailModal.vue'
  128. import mergeCustomerModal from './mergeCustomerModal.vue'
  129. export default {
  130. name: 'CustomerManagementList',
  131. components: { STable, VSelect, customerManagementDetailModal, rangeDate, AreaList, custType, mergeCustomerModal },
  132. mixins: [commonMixin],
  133. data () {
  134. return {
  135. spinning: false,
  136. advanced: false, // 高级搜索 展开/关闭
  137. tableHeight: 0,
  138. queryParam: { // 查询条件
  139. saleBeginDate: '',
  140. saleEndDate: '',
  141. customerName: undefined, // 客户名称
  142. contactName: '', // 联系人
  143. provinceSn: undefined, // 省
  144. citySn: undefined, // 市
  145. countySn: undefined, // 区
  146. dealerFlag: undefined, // 是否卫星仓客户
  147. customerTypeSn: undefined, // 客户类型
  148. enabledFlag: undefined, // 启用状态
  149. relationType: undefined
  150. },
  151. disabled: false, // 查询、重置按钮是否可操作
  152. columns: [
  153. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  154. { title: '客户名称', dataIndex: 'customerName', width: '28%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  155. { title: '联系人', dataIndex: 'contactName', width: '7%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  156. { title: '联系电话', dataIndex: 'contactTel', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '联系手机', dataIndex: 'contactMobile', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '最后销售时间', dataIndex: 'lastSaleTime', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  160. { title: '客户关系', dataIndex: 'relationTypeDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  161. // { title: '是否为下级', dataIndex: 'dealerFlagDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  162. { title: '价格类型', dataIndex: 'priceTypeDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  163. { title: '启用状态', scopedSlots: { customRender: 'enableAction' }, width: '8%', align: 'center' },
  164. { title: <div><a-tooltip placement='top' title='注意:客户合并功能中,将以当前客户为对象,合并被选客户。'><a-icon type="question-circle" /></a-tooltip>&nbsp;操作</div>, scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  165. ],
  166. // 加载数据方法 必须为 Promise 对象
  167. loadData: parameter => {
  168. this.disabled = true
  169. this.spinning = true
  170. return custList(Object.assign(parameter, this.queryParam)).then(res => {
  171. let data
  172. if (res.status == 200) {
  173. data = res.data
  174. const no = (data.pageNo - 1) * data.pageSize
  175. for (var i = 0; i < data.list.length; i++) {
  176. data.list[i].no = no + i + 1
  177. data.list[i].enabledFlag = data.list[i].enabledFlag + '' === '1'
  178. }
  179. this.disabled = false
  180. }
  181. this.spinning = false
  182. return data
  183. })
  184. },
  185. addrProvinceList: [], // 省下拉
  186. addrCityList: [], // 市下拉
  187. addrDistrictList: [], // 区下拉
  188. openModal: false, // 查看客户详情 弹框
  189. itemId: '', // 当前客户id
  190. openMergeModal: false, // 合并用户名称
  191. customerTemp: {}// 临时客户数据
  192. }
  193. },
  194. methods: {
  195. // 时间 change
  196. dateSaleChange (date) {
  197. this.queryParam.saleBeginDate = date[0] ? date[0] : ''
  198. this.queryParam.saleEndDate = date[1] ? date[1] : ''
  199. },
  200. areaChange (val) {
  201. this.queryParam.provinceSn = val[0] ? val[0] : undefined
  202. this.queryParam.citySn = val[1] ? val[1] : undefined
  203. this.queryParam.countySn = val[2] ? val[2] : undefined
  204. },
  205. // 重置
  206. resetSearchForm () {
  207. this.$refs.rangeSaleDate.resetDate()
  208. this.queryParam.saleBeginDate = ''
  209. this.queryParam.saleEndDate = ''
  210. this.queryParam.customerName = undefined
  211. this.queryParam.contactName = ''
  212. this.queryParam.provinceSn = undefined
  213. this.queryParam.citySn = undefined
  214. this.queryParam.countySn = undefined
  215. this.queryParam.dealerFlag = undefined
  216. this.queryParam.customerTypeSn = undefined
  217. this.queryParam.relationType = undefined
  218. this.queryParam.enabledFlag = undefined
  219. this.addrCityList = []
  220. this.addrDistrictList = []
  221. if (this.advanced) {
  222. this.$refs.areaList.clearData()
  223. }
  224. this.$refs.table.refresh(true)
  225. },
  226. // 新增/编辑
  227. handleEdit (row) {
  228. if (row) { // 编辑
  229. this.$router.push({ path: `/customerManagement/customerInfo/edit/${row.id}` })
  230. } else { // 新增
  231. this.$router.push({ path: '/customerManagement/customerInfo/add' })
  232. }
  233. },
  234. // 删除
  235. handleDel (row) {
  236. const _this = this
  237. this.$confirm({
  238. title: '提示',
  239. content: '删除后不可恢复,确定要进行删除吗?',
  240. centered: true,
  241. onOk () {
  242. _this.spinning = true
  243. custDel({ id: row.id }).then(res => {
  244. if (res.status == 200) {
  245. _this.$message.success(res.message)
  246. _this.$refs.table.refresh()
  247. _this.spinning = false
  248. } else {
  249. _this.spinning = false
  250. }
  251. })
  252. }
  253. })
  254. },
  255. // 修改状态
  256. changeFlagHandle (text, record) {
  257. const _data = {
  258. id: record.id,
  259. flag: record.enabledFlag ? '1' : '0'
  260. }
  261. this.spinning = true
  262. updateEnableStatus(_data).then(res => {
  263. if (res.status == 200) {
  264. this.$message.success(res.message)
  265. this.$refs.table.refresh()
  266. this.spinning = false
  267. } else {
  268. this.$refs.table.refresh()
  269. this.spinning = false
  270. }
  271. })
  272. },
  273. // 客户信息详情
  274. handleDetail (row) {
  275. this.itemId = row.id
  276. this.openModal = true
  277. },
  278. // 合并客户
  279. mergeCustomer (row) {
  280. this.customerTemp = row
  281. this.openMergeModal = true
  282. },
  283. closeMergeModal (flag) {
  284. this.customerTemp = ''
  285. this.openMergeModal = false
  286. if (flag) {
  287. this.$refs.table.refresh()
  288. }
  289. },
  290. // 关闭弹框
  291. closeModal () {
  292. this.itemId = ''
  293. this.openModal = false
  294. },
  295. filterOption (input, option) {
  296. return (
  297. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  298. )
  299. },
  300. pageInit () {
  301. const _this = this
  302. this.$nextTick(() => { // 页面渲染完成后的回调
  303. _this.setTableH()
  304. })
  305. },
  306. setTableH () {
  307. const tableSearchH = this.$refs.tableSearch.offsetHeight
  308. this.tableHeight = window.innerHeight - tableSearchH - 220
  309. }
  310. },
  311. watch: {
  312. advanced (newValue, oldValue) {
  313. const _this = this
  314. this.$nextTick(() => { // 页面渲染完成后的回调
  315. _this.setTableH()
  316. })
  317. },
  318. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  319. this.setTableH()
  320. }
  321. },
  322. mounted () {
  323. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  324. this.pageInit()
  325. this.resetSearchForm()
  326. }
  327. },
  328. activated () {
  329. // 如果是新页签打开,则重置当前页面
  330. if (this.$store.state.app.isNewTab) {
  331. this.pageInit()
  332. this.resetSearchForm()
  333. }
  334. // 仅刷新列表,不重置页面
  335. if (this.$store.state.app.updateList) {
  336. this.pageInit()
  337. this.$refs.table.refresh()
  338. }
  339. },
  340. beforeRouteEnter (to, from, next) {
  341. next(vm => {})
  342. }
  343. }
  344. </script>