list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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="{ y: tableHeight }"
  91. :defaultLoadData="false"
  92. bordered>
  93. <!-- 操作 -->
  94. <template slot="action" slot-scope="text, record">
  95. <a-button
  96. size="small"
  97. v-if="$hasPermissions('B_customer_customerInfo_edit')"
  98. type="link"
  99. class="button-info"
  100. @click="handleEdit(record)"
  101. id="customerManagementList-edit-btn">编辑</a-button>
  102. <a-button
  103. size="small"
  104. v-if="$hasPermissions('B_customer_customerInfo_detail')"
  105. type="link"
  106. class="button-success"
  107. @click="handleDetail(record)"
  108. id="customerManagementList-detail-btn">详情</a-button>
  109. <span v-if="!$hasPermissions('B_customer_customerInfo_edit') && !$hasPermissions('B_customer_customerInfo_detail')">--</span>
  110. </template>
  111. <template slot="enableAction" slot-scope="text, record">
  112. <a-switch v-if="$hasPermissions('B_customer_customerInfo_enable')" checkedChildren="启用" unCheckedChildren="禁用" v-model="record.enabledFlag" @change="changeFlagHandle(text, record)"/>
  113. <span v-else :style="{color:(record.enabledFlag==1?'#00aa00':'#999')}"> {{ record.enabledFlag==1? '已启用': '已禁用' }} </span>
  114. </template>
  115. </s-table>
  116. </a-spin>
  117. <!-- 客户详情 -->
  118. <customer-management-detail-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  119. </a-card>
  120. </template>
  121. <script>
  122. import { commonMixin } from '@/utils/mixin'
  123. import { getArea } from '@/api/data'
  124. import { custList, custDel, updateEnableStatus } from '@/api/customer'
  125. import { custTypeFindAllList } from '@/api/custType'
  126. import { STable, VSelect } from '@/components'
  127. import rangeDate from '@/views/common/rangeDate.vue'
  128. import customerManagementDetailModal from './detailModal.vue'
  129. export default {
  130. name: 'CustomerManagementList',
  131. components: { STable, VSelect, customerManagementDetailModal, rangeDate },
  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. satelliteFlag: undefined, // 是否卫星仓客户
  147. customerTypeSn: undefined // 客户类型
  148. },
  149. disabled: false, // 查询、重置按钮是否可操作
  150. columns: [
  151. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  152. { title: '客户名称', dataIndex: 'customerName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  153. { title: '联系人', dataIndex: 'contactName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  154. { title: '联系电话', dataIndex: 'contactTel', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  155. { title: '联系手机', dataIndex: 'contactMobile', width: '9%', align: 'center', customRender: function (text) { return text || '--' } },
  156. { title: '创建时间', dataIndex: 'createDate', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  157. { title: '最后销售时间', dataIndex: 'lastSaleTime', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '是否卫星仓', dataIndex: 'satelliteFlagDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '启用禁用', scopedSlots: { customRender: 'enableAction' }, width: '8%', align: 'center' },
  160. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  161. ],
  162. // 加载数据方法 必须为 Promise 对象
  163. loadData: parameter => {
  164. this.disabled = true
  165. this.spinning = true
  166. return custList(Object.assign(parameter, this.queryParam)).then(res => {
  167. let data
  168. if (res.status == 200) {
  169. data = res.data
  170. const no = (data.pageNo - 1) * data.pageSize
  171. for (var i = 0; i < data.list.length; i++) {
  172. data.list[i].no = no + i + 1
  173. data.list[i].enabledFlag = data.list[i].enabledFlag + '' === '1'
  174. }
  175. this.disabled = false
  176. }
  177. this.spinning = false
  178. return data
  179. })
  180. },
  181. addrProvinceList: [], // 省下拉
  182. addrCityList: [], // 市下拉
  183. addrDistrictList: [], // 区下拉
  184. custTypeList: [], // 客户类型 下拉数据
  185. openModal: false, // 查看客户详情 弹框
  186. itemId: '' // 当前客户id
  187. }
  188. },
  189. methods: {
  190. // 时间 change
  191. dateSaleChange (date) {
  192. this.queryParam.saleBeginDate = date[0] ? date[0] + ' 00:00:00' : ''
  193. this.queryParam.saleEndDate = date[1] ? date[1] + ' 23:59:59' : ''
  194. },
  195. // 重置
  196. resetSearchForm () {
  197. this.$refs.rangeSaleDate.resetDate()
  198. this.queryParam.saleBeginDate = ''
  199. this.queryParam.saleEndDate = ''
  200. this.queryParam.customerName = undefined
  201. this.queryParam.contactName = ''
  202. this.queryParam.provinceSn = undefined
  203. this.queryParam.citySn = undefined
  204. this.queryParam.countySn = undefined
  205. this.queryParam.satelliteFlag = undefined
  206. this.queryParam.customerTypeSn = undefined
  207. this.addrCityList = []
  208. this.addrDistrictList = []
  209. this.$refs.table.refresh(true)
  210. },
  211. // 新增/编辑
  212. handleEdit (row) {
  213. if (row) { // 编辑
  214. this.$router.push({ path: `/customerManagement/customerInfo/edit/${row.id}` })
  215. } else { // 新增
  216. this.$router.push({ path: '/customerManagement/customerInfo/add' })
  217. }
  218. },
  219. // 删除
  220. handleDel (row) {
  221. const _this = this
  222. this.$confirm({
  223. title: '提示',
  224. content: '删除后不可恢复,确定要进行删除吗?',
  225. centered: true,
  226. onOk () {
  227. _this.spinning = true
  228. custDel({ id: row.id }).then(res => {
  229. if (res.status == 200) {
  230. _this.$message.success(res.message)
  231. _this.$refs.table.refresh()
  232. _this.spinning = false
  233. } else {
  234. _this.spinning = false
  235. }
  236. })
  237. }
  238. })
  239. },
  240. // 修改状态
  241. changeFlagHandle (text, record) {
  242. const _data = {
  243. id: record.id,
  244. flag: record.enabledFlag ? '1' : '0'
  245. }
  246. this.spinning = true
  247. updateEnableStatus(_data).then(res => {
  248. if (res.status == 200) {
  249. this.$message.success(res.message)
  250. this.$refs.table.refresh()
  251. this.spinning = false
  252. } else {
  253. this.$refs.table.refresh()
  254. this.spinning = false
  255. }
  256. })
  257. },
  258. // 客户合并
  259. handleMerge () {},
  260. // 客户信息详情
  261. handleDetail (row) {
  262. this.itemId = row.id
  263. this.openModal = true
  264. },
  265. // 关闭弹框
  266. closeModal () {
  267. this.itemId = ''
  268. this.openModal = false
  269. },
  270. filterOption (input, option) {
  271. return (
  272. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  273. )
  274. },
  275. // 获取客户类型列表
  276. getCustTypeList () {
  277. const _this = this
  278. custTypeFindAllList().then(res => {
  279. if (res.status == 200) {
  280. _this.custTypeList = res.data || []
  281. } else {
  282. _this.custTypeList = []
  283. }
  284. })
  285. },
  286. // 获取城市列表
  287. getCityList (val) {
  288. this.addrCityList = []
  289. this.addrDistrictList = []
  290. this.queryParam.citySn = undefined
  291. this.queryParam.countySn = undefined
  292. if (val) {
  293. this.getArea('city', val)
  294. }
  295. },
  296. // 获取区县列表
  297. getAreaList (val) {
  298. this.addrDistrictList = []
  299. this.queryParam.countySn = undefined
  300. if (val) {
  301. this.getArea('district', val)
  302. }
  303. },
  304. // 省/市/区
  305. getArea (leve, sn) {
  306. let params
  307. if (leve == 'province') {
  308. params = { type: '2' }
  309. } else {
  310. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  311. }
  312. getArea(params).then(res => {
  313. if (res.status == 200) {
  314. if (leve == 'province') {
  315. this.addrProvinceList = res.data || []
  316. } else if (leve == 'city') {
  317. this.addrCityList = res.data || []
  318. } else if (leve == 'district') {
  319. this.addrDistrictList = res.data || []
  320. }
  321. } else {
  322. if (leve == 'province') {
  323. this.addrProvinceList = []
  324. } else if (leve == 'city') {
  325. this.addrCityList = []
  326. } else if (leve == 'district') {
  327. this.addrDistrictList = []
  328. }
  329. }
  330. })
  331. },
  332. pageInit () {
  333. const _this = this
  334. this.$nextTick(() => { // 页面渲染完成后的回调
  335. _this.setTableH()
  336. })
  337. this.getArea('province')
  338. this.getCustTypeList()
  339. },
  340. setTableH () {
  341. const tableSearchH = this.$refs.tableSearch.offsetHeight
  342. this.tableHeight = window.innerHeight - tableSearchH - 235
  343. }
  344. },
  345. watch: {
  346. advanced (newValue, oldValue) {
  347. const _this = this
  348. this.$nextTick(() => { // 页面渲染完成后的回调
  349. _this.setTableH()
  350. })
  351. },
  352. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  353. this.setTableH()
  354. }
  355. },
  356. mounted () {
  357. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  358. this.pageInit()
  359. this.resetSearchForm()
  360. }
  361. },
  362. activated () {
  363. // 如果是新页签打开,则重置当前页面
  364. if (this.$store.state.app.isNewTab) {
  365. this.pageInit()
  366. this.resetSearchForm()
  367. }
  368. // 仅刷新列表,不重置页面
  369. if (this.$store.state.app.updateList) {
  370. this.pageInit()
  371. this.$refs.table.refresh()
  372. }
  373. },
  374. beforeRouteEnter (to, from, next) {
  375. next(vm => {})
  376. }
  377. }
  378. </script>