viewDealers.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div>
  3. <a-drawer
  4. title="查看经销商"
  5. width="80%"
  6. :zIndex="100"
  7. :visible="visible"
  8. :get-container="false"
  9. class="viewsDealer"
  10. :wrap-style="{ position: 'absolute' }"
  11. @close="visible = false">
  12. <a-spin :spinning="spinning" tip="Loading...">
  13. <!-- 搜索条件 -->
  14. <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
  15. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  16. <a-row :gutter="15">
  17. <a-col :md="8" :sm="24">
  18. <a-form-item label="经销商名称/别名">
  19. <a-input id="viewDealers-nameLike" v-model.trim="queryParam.dealer.nameLike" allowClear placeholder="请输入经销商名称/别名"/>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="8" :sm="24">
  23. <a-form-item label="商户类型">
  24. <v-select code="DEALER_TYPE" id="viewDealers-dealerType" v-model="queryParam.dealer.dealerType" allowClear placeholder="请选择商户类型"></v-select>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="8" :sm="24">
  28. <a-form-model-item label="商户级别">
  29. <v-select code="DEALER_LEVEL" id="viewDealers-dealerLevel" v-model="queryParam.dealer.dealerLevel" allowClear placeholder="请选择商户级别"></v-select>
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :md="8" :sm="24">
  33. <a-form-item label="审核状态">
  34. <v-select code="AUDIT_STATE" id="viewDealers-auditState" v-model="queryParam.dealer.auditState" allowClear placeholder="请选择审核状态"></v-select>
  35. </a-form-item>
  36. </a-col>
  37. <a-col :md="8" :sm="24">
  38. <a-form-model-item label="地区">
  39. <AreaList id="viewDealers-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  40. </a-form-model-item>
  41. </a-col>
  42. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  43. <a-button type="primary" @click="searchForm" :disabled="disabled" id="viewDealers-refresh">查询</a-button>
  44. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="viewDealers-reset">重置</a-button>
  45. </a-col>
  46. </a-row>
  47. </a-form>
  48. </div>
  49. <div style="margin-top:200px;" v-if="flag">
  50. <a-empty
  51. :image="simpleImage"
  52. :image-style="{
  53. height: '60px',
  54. }"
  55. >
  56. <span slot="description"> 暂无数据 </span>
  57. <a-button type="primary" class="button-error" @click="openAddDealer=true"><a-icon type="plus" />立即绑定经销商</a-button>
  58. </a-empty>
  59. </div>
  60. <div class="tableCon" v-else>
  61. <div style="margin-bottom:10px;"><a-button type="primary" class="button-error" @click="openAddDealer=true">绑定经销商</a-button></div>
  62. <s-table
  63. class="sTable"
  64. ref="table"
  65. size="small"
  66. :rowKey="(record) => record.id"
  67. :columns="columns"
  68. :data="loadData"
  69. :style="{ height: tableHeight+84.5+'px' }"
  70. :scroll="{ y: tableHeight }"
  71. bordered>
  72. <template slot="action" slot-scope="text, record">
  73. <a-button
  74. size="small"
  75. type="link"
  76. class="button-error"
  77. @click="handleDel(record)"
  78. >删除</a-button>
  79. </template>
  80. </s-table>
  81. </div>
  82. </a-spin>
  83. </a-drawer>
  84. <!-- 绑定经销商 -->
  85. <a-drawer
  86. title="绑定经销商"
  87. width="68%"
  88. :zIndex="200"
  89. :visible="openAddDealer"
  90. :get-container="false"
  91. :wrap-style="{ position: 'absolute' }"
  92. class="deraw-bindDealer"
  93. @close="openAddDealer = false">
  94. <div class="dealerModalCon">
  95. <chooseDealer
  96. ref="chooseDealer"
  97. v-if="openAddDealer"
  98. :parentData="parentData"
  99. pageType="viewDealers"
  100. @add="hanldAdd"
  101. @plAdd="hanldPlAdd"></chooseDealer>
  102. </div>
  103. </a-drawer>
  104. </div>
  105. </template>
  106. <script>
  107. import { commonMixin } from '@/utils/mixin'
  108. import { STable, VSelect } from '@/components'
  109. import chooseDealer from '@/views/common/chooseDealer.vue'
  110. import AreaList from '@/views/common/areaList.js'
  111. import { Empty } from 'ant-design-vue'
  112. import { queryPageAreaDealer, batchBindDealer, bindDealer, deleteBindDealer } from '@/api/subarea'
  113. export default {
  114. mixins: [commonMixin],
  115. components: { STable, VSelect, chooseDealer, AreaList },
  116. props: {
  117. showModal: {
  118. type: Boolean,
  119. default: false
  120. },
  121. parentData: {
  122. type: Object,
  123. default: function () {
  124. return null
  125. }
  126. }
  127. },
  128. watch: {
  129. showModal (newValue, oldValue) {
  130. this.visible = newValue
  131. },
  132. visible (newValue, oldValue) {
  133. if (!newValue) {
  134. this.$emit('close')
  135. this.resetData()
  136. } else {
  137. this.pageInit()
  138. }
  139. },
  140. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  141. this.setTableH()
  142. }
  143. },
  144. data () {
  145. return {
  146. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  147. spinning: false,
  148. visible: this.showModal,
  149. openAddDealer: false,
  150. flag: true,
  151. queryParam: { // 查询条件
  152. dealer: {
  153. nameLike: '',
  154. dealerType: null,
  155. dealerLevel: null,
  156. auditState: undefined,
  157. provinceSn: undefined,
  158. citySn: undefined,
  159. districtSn: undefined
  160. }
  161. },
  162. addrProvinceList: [], // 省下拉
  163. addrCityList: [], // 市下拉
  164. addrDistrictList: [], // 区下拉
  165. disabled: false,
  166. tableHeight: 0,
  167. columns: [
  168. { title: '经销商名称', dataIndex: 'dealer.dealerName', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '商户别名', dataIndex: 'dealer.dealerAlias', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  170. { title: '商户类型', dataIndex: 'dealer.dealerTypeDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  171. { title: '商户级别', dataIndex: 'dealer.dealerLevelDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  172. { title: '审核状态', dataIndex: 'dealer.auditStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  173. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  174. ],
  175. loadData: parameter => {
  176. this.disabled = true
  177. this.spinning = true
  178. return queryPageAreaDealer(Object.assign(parameter, this.queryParam, { subareaSn: this.parentData.subareaSn, subareaAreaSn: this.parentData.subareaAreaSn })).then(res => {
  179. let data
  180. if (res.status == 200) {
  181. data = res.data
  182. const no = 0
  183. for (var i = 0; i < data.length; i++) {
  184. data[i].no = no + i + 1
  185. }
  186. }
  187. this.disabled = false
  188. this.spinning = false
  189. this.setTableH()
  190. return data
  191. })
  192. }
  193. }
  194. },
  195. methods: {
  196. // 绑定
  197. hanldAdd (row) {
  198. console.log(row)
  199. bindDealer({ subareaAreaSn: this.parentData.subareaAreaSn, dealerSn: row.dealerSn }).then(res => {
  200. if (res.status == 200) {
  201. this.resetSearchForm()
  202. this.$refs.chooseDealer.searchForm(false)
  203. }
  204. this.$refs.chooseDealer.searchForm
  205. })
  206. },
  207. // 批量绑定
  208. hanldPlAdd (rows) {
  209. console.log(rows)
  210. batchBindDealer({ subareaAreaSn: this.parentData.subareaAreaSn, dealerSnSet: rows }).then(res => {
  211. if (res.status == 200) {
  212. this.resetSearchForm()
  213. this.$refs.chooseDealer.searchForm(false)
  214. }
  215. this.$refs.chooseDealer.spinning = false
  216. })
  217. },
  218. // 删除
  219. handleDel (row) {
  220. const _this = this
  221. this.$confirm({
  222. title: '提示',
  223. content: '确定要删除当前经销商绑定关系吗?',
  224. centered: true,
  225. onOk () {
  226. _this.spinning = true
  227. deleteBindDealer({ sn: row.subareaAreaDealerSn }).then(res => {
  228. if (res.status == 200) {
  229. _this.resetSearchForm()
  230. }
  231. _this.spinning = false
  232. })
  233. }
  234. })
  235. },
  236. searchForm () {
  237. if (this.flag) {
  238. this.hasData()
  239. } else {
  240. this.$refs.table.refresh(true)
  241. }
  242. },
  243. resetData () {
  244. this.queryParam = {
  245. dealer: {
  246. nameLike: '',
  247. dealerType: null,
  248. dealerLevel: null,
  249. auditState: undefined,
  250. provinceSn: undefined,
  251. citySn: undefined,
  252. districtSn: undefined
  253. }
  254. }
  255. this.$refs.areaList.clearData()
  256. },
  257. resetSearchForm () {
  258. if (this.flag) {
  259. this.hasData()
  260. } else {
  261. this.resetData()
  262. this.$refs.table.refresh(true)
  263. }
  264. },
  265. areaChange (val) {
  266. this.queryParam.dealer.provinceSn = val[0] ? val[0] : ''
  267. this.queryParam.dealer.citySn = val[1] ? val[1] : ''
  268. this.queryParam.dealer.districtSn = val[2] ? val[2] : ''
  269. },
  270. async hasData () {
  271. const ret = await queryPageAreaDealer({ pageNo: 1, pageSize: 10, subareaSn: this.parentData.subareaSn, subareaAreaSn: this.parentData.subareaAreaSn }).then(res => res.data)
  272. this.flag = ret.count == 0
  273. },
  274. pageInit () {
  275. const _this = this
  276. this.$nextTick(() => { // 页面渲染完成后的回调
  277. _this.setTableH()
  278. })
  279. this.flag = true
  280. // 判断是已绑定数据
  281. this.hasData()
  282. },
  283. setTableH () {
  284. const tableSearchH = this.$refs.tableSearch.offsetHeight
  285. this.tableHeight = window.innerHeight - tableSearchH - 290
  286. }
  287. }
  288. }
  289. </script>
  290. <style lang="less">
  291. .viewsDealer{
  292. .ant-drawer-body{
  293. padding:10px 20px 0;
  294. }
  295. }
  296. .deraw-bindDealer {
  297. .ant-drawer-body{
  298. padding:10px 20px 0;
  299. }
  300. }
  301. </style>