list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <a-card size="small" :bordered="false" class="customerManagementList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="创建时间">
  9. <a-range-picker
  10. style="width:100%"
  11. id="customerManagementList-creatTime"
  12. :disabledDate="disabledDate"
  13. v-model="creatTime"
  14. :format="dateFormat"
  15. :placeholder="['开始时间', '结束时间']" />
  16. </a-form-item>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-form-item label="客户名称">
  21. <a-select
  22. id="customerManagementList-customerName"
  23. placeholder="请选择"
  24. allowClear
  25. v-model="queryParam.customerName"
  26. :showSearch="true"
  27. option-filter-prop="children"
  28. :filter-option="filterOption">
  29. <a-select-option v-for="item in custList" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
  30. </a-select>
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="联系人">
  35. <a-input id="customerManagementList-contactName" v-model.trim="queryParam.contactName" allowClear placeholder="请输入联系人"/>
  36. </a-form-item>
  37. </a-col>
  38. <template v-if="advanced">
  39. <a-col :md="6" :sm="24">
  40. <a-form-item label="最后销售时间">
  41. <a-range-picker
  42. style="width:100%"
  43. id="customerManagementList-lastSaleTime"
  44. :disabledDate="disabledDate"
  45. v-model="lastSaleTime"
  46. :format="dateFormat"
  47. :placeholder="['开始时间', '结束时间']" />
  48. </a-form-item>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :md="12" :sm="24">
  52. <a-row>
  53. <!-- 客户地址 -->
  54. <a-form-item label="客户地址">
  55. <a-col span="7">
  56. <a-form-item prop="provinceSn" style="margin: 0;">
  57. <a-select v-model="queryParam.provinceSn" @change="getCityList" placeholder="请选择省">
  58. <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
  59. </a-select>
  60. </a-form-item>
  61. </a-col>
  62. <a-col span="7" offset="1">
  63. <a-form-item prop="citySn" style="margin: 0;">
  64. <a-select v-model="queryParam.citySn" @change="getAreaList" placeholder="请选择市">
  65. <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
  66. </a-select>
  67. </a-form-item>
  68. </a-col>
  69. <a-col span="7" offset="1">
  70. <a-form-item prop="countySn" style="margin: 0;">
  71. <a-select v-model="queryParam.countySn" placeholder="请选择区/县">
  72. <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
  73. </a-select>
  74. </a-form-item>
  75. </a-col>
  76. </a-form-item>
  77. </a-row>
  78. </a-col>
  79. <a-col :md="6" :sm="24">
  80. <a-form-item label="是否卫星仓客户">
  81. <v-select code="FLAG" id="customerManagementList-satelliteFlag" v-model="queryParam.satelliteFlag" allowClear placeholder="请选择"></v-select>
  82. </a-form-item>
  83. </a-col>
  84. <a-col :md="6" :sm="24">
  85. <a-form-item label="客户类型">
  86. <a-select v-model="queryParam.customerTypeSn" placeholder="请选择客户类型">
  87. <a-select-option v-for="item in custTypeList" :value="item.customersTypeSn" :key="item.customersTypeSn">{{ item.customersTypeName }}</a-select-option>
  88. </a-select>
  89. </a-form-item>
  90. </a-col>
  91. </template>
  92. <a-col :md="6" :sm="24" style="margin-bottom: 15px;">
  93. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="customerManagementList-refresh">查询</a-button>
  94. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="customerManagementList-reset">重置</a-button>
  95. <a @click="advanced=!advanced" style="margin-left: 8px">
  96. {{ advanced ? '收起' : '展开' }}
  97. <a-icon :type="advanced ? 'up' : 'down'"/>
  98. </a>
  99. </a-col>
  100. </a-row>
  101. </a-form>
  102. </div>
  103. <!-- 操作按钮 -->
  104. <div class="table-operator">
  105. <a-button id="customerManagementList-add" type="primary" @click="handleEdit()">新增客户</a-button>
  106. <!-- <a-button id="customerManagementList-merge" @click="handleMerge" style="margin: 0 0 0 15px;">客户合并</a-button> -->
  107. </div>
  108. <!-- 列表 -->
  109. <s-table
  110. class="sTable"
  111. ref="table"
  112. size="default"
  113. :rowKey="(record) => record.id"
  114. :columns="columns"
  115. :data="loadData"
  116. :scroll="{ x: 1100 }"
  117. bordered>
  118. <!-- 操作 -->
  119. <template slot="action" slot-scope="text, record">
  120. <a-button size="small" type="link" @click="handleEdit(record)" id="customerManagementList-edit-btn">编辑</a-button>
  121. <a-divider type="vertical" style="margin: 0;" />
  122. <a-button size="small" type="link" @click="handleDetail(record)" id="customerManagementList-detail-btn">详情</a-button>
  123. <a-divider type="vertical" style="margin: 0;" />
  124. <a-button size="small" type="link" @click="handleDel(record)" id="customerManagementList-del-btn">删除</a-button>
  125. </template>
  126. </s-table>
  127. <!-- 客户详情 -->
  128. <customer-management-detail-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  129. </a-card>
  130. </template>
  131. <script>
  132. import moment from 'moment'
  133. import { getArea } from '@/api/data'
  134. import { custList, custDel } from '@/api/customer'
  135. import { custTypeFindAll } from '@/api/custType'
  136. import { STable, VSelect } from '@/components'
  137. import customerManagementDetailModal from './detailModal.vue'
  138. export default {
  139. components: { STable, VSelect, customerManagementDetailModal },
  140. data () {
  141. return {
  142. advanced: false, // 高级搜索 展开/关闭
  143. queryParam: { // 查询条件
  144. customerName: undefined, // 客户名称
  145. contactName: '', // 联系人
  146. provinceSn: undefined, // 省
  147. citySn: undefined, // 市
  148. countySn: undefined, // 区
  149. satelliteFlag: undefined, // 是否卫星仓客户
  150. customerTypeSn: undefined // 客户类型
  151. },
  152. disabled: false, // 查询、重置按钮是否可操作
  153. dateFormat: 'YYYY-MM-DD',
  154. creatTime: [], // 创建时间
  155. lastSaleTime: [], // 最后销售时间
  156. columns: [
  157. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  158. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  159. { title: '客户名称', dataIndex: 'customerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  160. { title: '联系人', dataIndex: 'contactName', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  161. { title: '联系电话', dataIndex: 'contactTel', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  162. { title: '最后销售时间', dataIndex: 'lastSaleTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  163. { title: '是否卫星仓', dataIndex: 'satelliteFlag', width: 110, align: 'center', customRender: function (text) { return text || '--' } },
  164. { title: '操作', scopedSlots: { customRender: 'action' }, width: 170, align: 'center', fixed: 'right' }
  165. ],
  166. // 加载数据方法 必须为 Promise 对象
  167. loadData: parameter => {
  168. this.disabled = true
  169. // 创建时间
  170. if (this.creatTime && this.creatTime.length > 0) {
  171. this.queryParam.beginDate = moment(this.creatTime[0]).format(this.dateFormat)
  172. this.queryParam.endDate = moment(this.creatTime[1]).format(this.dateFormat)
  173. } else {
  174. this.queryParam.beginDate = undefined
  175. this.queryParam.endDate = undefined
  176. }
  177. // 最后销售时间
  178. if (this.lastSaleTime && this.lastSaleTime.length > 0) {
  179. this.queryParam.saleBeginDate = moment(this.lastSaleTime[0]).format(this.dateFormat)
  180. this.queryParam.saleEndDate = moment(this.lastSaleTime[1]).format(this.dateFormat)
  181. } else {
  182. this.queryParam.saleBeginDate = undefined
  183. this.queryParam.saleEndDate = undefined
  184. }
  185. return custList(Object.assign(parameter, this.queryParam)).then(res => {
  186. const data = res.data
  187. const no = (data.pageNo - 1) * data.pageSize
  188. for (var i = 0; i < data.list.length; i++) {
  189. data.list[i].no = no + i + 1
  190. }
  191. this.disabled = false
  192. return data
  193. })
  194. },
  195. addrProvinceList: [], // 省下拉
  196. addrCityList: [], // 市下拉
  197. addrDistrictList: [], // 区下拉
  198. custList: [], // 客户 下拉数据
  199. custTypeList: [], // 客户类型 下拉数据
  200. openModal: false, // 查看客户详情 弹框
  201. itemId: '' // 当前客户id
  202. }
  203. },
  204. methods: {
  205. // 不可选日期
  206. disabledDate (date, dateStrings) {
  207. return date && date.valueOf() > Date.now()
  208. },
  209. // 重置
  210. resetSearchForm () {
  211. this.queryParam.customerName = ''
  212. this.queryParam.contactName = ''
  213. this.queryParam.provinceSn = undefined
  214. this.queryParam.citySn = undefined
  215. this.queryParam.countySn = undefined
  216. this.queryParam.satelliteFlag = undefined
  217. this.queryParam.customerTypeSn = undefined
  218. this.creatTime = []
  219. this.lastSaleTime = []
  220. this.$refs.table.refresh(true)
  221. },
  222. // 新增/编辑
  223. handleEdit (row) {
  224. if (row) { // 编辑
  225. this.$router.push({ path: `/customerManagement/customerInfo/edit/${row.id}` })
  226. } else { // 新增
  227. this.$router.push({ path: '/customerManagement/customerInfo/add' })
  228. }
  229. },
  230. // 删除
  231. handleDel (row) {
  232. const _this = this
  233. this.$confirm({
  234. title: '提示',
  235. content: '删除后不可恢复,确定要进行删除吗?',
  236. okText: '确定',
  237. cancelText: '取消',
  238. centered: true,
  239. onOk () {
  240. custDel({
  241. id: row.id
  242. }).then(res => {
  243. if (res.status == 200) {
  244. _this.$message.success(res.message)
  245. _this.$refs.table.refresh()
  246. }
  247. })
  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. custTypeFindAll().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.form.cityCode = undefined
  284. this.form.districtCode = undefined
  285. this.form.address = ''
  286. this.getArea('city', val)
  287. },
  288. // 获取区县列表
  289. getAreaList (val) {
  290. this.addrDistrictList = []
  291. this.form.districtCode = undefined
  292. this.form.address = ''
  293. this.getArea('district', val)
  294. },
  295. // 区县变更
  296. areaCharged (val) {
  297. this.form.address = ''
  298. },
  299. // 省/市/区
  300. getArea (type, sn) {
  301. let params
  302. if (type == 'province') {
  303. params = { level: '1' }
  304. } else {
  305. params = { psn: sn }
  306. }
  307. getArea(params).then(res => {
  308. if (res.status == 200) {
  309. if (type == 'province') {
  310. this.addrProvinceList = res.data || []
  311. } else if (type == 'city') {
  312. this.addrCityList = res.data || []
  313. } else if (type == 'district') {
  314. this.addrDistrictList = res.data || []
  315. }
  316. } else {
  317. if (type == 'province') {
  318. this.addrProvinceList = []
  319. } else if (type == 'city') {
  320. this.addrCityList = []
  321. } else if (type == 'district') {
  322. this.addrDistrictList = []
  323. }
  324. }
  325. })
  326. }
  327. },
  328. beforeRouteEnter (to, from, next) {
  329. next(vm => {
  330. vm.getArea('province')
  331. vm.getCustTypeList()
  332. })
  333. }
  334. }
  335. </script>