list.vue 15 KB

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