list.vue 13 KB

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