list.vue 14 KB

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