list.vue 14 KB

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