viewDealers.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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="text-align:right;margin-bottom:10px;"><a-button type="primary" class="button-error" @click="openAddDealer=true"><a-icon type="plus" />绑定经销商</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 ref="chooseDealer" v-if="openAddDealer" :parentData="parentData" pageType="viewDealers" @add="hanldAdd" @plAdd="hanldPlAdd"></chooseDealer>
  96. </div>
  97. </a-drawer>
  98. </div>
  99. </template>
  100. <script>
  101. import { commonMixin } from '@/utils/mixin'
  102. import { STable, VSelect } from '@/components'
  103. import chooseDealer from '@/views/common/chooseDealer.vue'
  104. import AreaList from '@/views/common/areaList.js'
  105. import { Empty } from 'ant-design-vue'
  106. import { queryPageAreaDealer, batchBindDealer, bindDealer, deleteBindDealer } from '@/api/subarea'
  107. export default {
  108. mixins: [commonMixin],
  109. components: { STable, VSelect, chooseDealer, AreaList },
  110. props: {
  111. showModal: {
  112. type: Boolean,
  113. default: false
  114. },
  115. parentData: {
  116. type: Object,
  117. default: function(){
  118. return null
  119. }
  120. }
  121. },
  122. watch: {
  123. showModal (newValue, oldValue) {
  124. this.visible = newValue
  125. },
  126. visible (newValue, oldValue) {
  127. if (!newValue) {
  128. this.$emit('close')
  129. this.resetData()
  130. }else{
  131. this.pageInit()
  132. }
  133. },
  134. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  135. this.setTableH()
  136. }
  137. },
  138. data () {
  139. return {
  140. simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
  141. spinning: false,
  142. visible: this.showModal,
  143. openAddDealer: false,
  144. flag: true,
  145. queryParam: { // 查询条件
  146. dealer:{
  147. nameLike: '',
  148. dealerType: null,
  149. dealerLevel: null,
  150. auditState: undefined,
  151. provinceSn: undefined,
  152. citySn: undefined,
  153. districtSn: undefined
  154. }
  155. },
  156. addrProvinceList: [], // 省下拉
  157. addrCityList: [], // 市下拉
  158. addrDistrictList: [], // 区下拉
  159. disabled: false,
  160. tableHeight: 0,
  161. columns: [
  162. { title: '经销商名称', dataIndex: 'dealer.dealerName', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  163. { title: '商户别名', dataIndex: 'dealer.dealerAlias', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  164. { title: '商户类型', dataIndex: 'dealer.dealerTypeDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  165. { title: '商户级别', dataIndex: 'dealer.dealerLevelDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  166. { title: '审核状态', dataIndex: 'dealer.auditStateDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  167. { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
  168. ],
  169. loadData: parameter => {
  170. this.disabled = true
  171. this.spinning = true
  172. return queryPageAreaDealer(Object.assign(parameter, this.queryParam, {subareaSn: this.parentData.subareaSn, subareaAreaSn: this.parentData.subareaAreaSn})).then(res => {
  173. let data
  174. if (res.status == 200) {
  175. data = res.data
  176. const no = 0
  177. for (var i = 0; i < data.length; i++) {
  178. data[i].no = no + i + 1
  179. }
  180. }
  181. this.disabled = false
  182. this.spinning = false
  183. this.setTableH()
  184. return data
  185. })
  186. },
  187. }
  188. },
  189. methods: {
  190. // 绑定
  191. hanldAdd(row){
  192. console.log(row)
  193. bindDealer({subareaAreaSn: this.parentData.subareaAreaSn,dealerSn:row.dealerSn}).then(res => {
  194. if(res.status == 200){
  195. this.resetSearchForm()
  196. this.$refs.chooseDealer.searchForm(false)
  197. }
  198. this.$refs.chooseDealer.searchForm
  199. })
  200. },
  201. // 批量绑定
  202. hanldPlAdd(rows){
  203. console.log(rows)
  204. batchBindDealer({subareaAreaSn: this.parentData.subareaAreaSn,dealerSnSet:rows}).then(res => {
  205. if(res.status == 200){
  206. this.resetSearchForm()
  207. this.$refs.chooseDealer.searchForm(false)
  208. }
  209. this.$refs.chooseDealer.spinning = false
  210. })
  211. },
  212. // 删除
  213. handleDel(row){
  214. const _this = this
  215. this.$confirm({
  216. title: '提示',
  217. content: '确定要删除当前经销商绑定关系吗?',
  218. centered: true,
  219. onOk () {
  220. _this.spinning = true
  221. deleteBindDealer({sn: row.subareaAreaDealerSn}).then(res => {
  222. if(res.status == 200){
  223. _this.resetSearchForm()
  224. }
  225. _this.spinning = false
  226. })
  227. }
  228. })
  229. },
  230. searchForm(){
  231. if(this.flag){
  232. this.hasData()
  233. }else{
  234. this.$refs.table.refresh(true)
  235. }
  236. },
  237. resetData(){
  238. this.queryParam = {
  239. dealer:{
  240. nameLike: '',
  241. dealerType: null,
  242. dealerLevel: null,
  243. auditState: undefined,
  244. provinceSn: undefined,
  245. citySn: undefined,
  246. districtSn: undefined
  247. }
  248. }
  249. this.$refs.areaList.clearData()
  250. },
  251. resetSearchForm () {
  252. if(this.flag){
  253. this.hasData()
  254. }else{
  255. this.resetData()
  256. this.$refs.table.refresh(true)
  257. }
  258. },
  259. areaChange(val){
  260. this.queryParam.dealer.provinceSn = val[0] ? val[0] : ''
  261. this.queryParam.dealer.citySn = val[1] ? val[1] : ''
  262. this.queryParam.dealer.districtSn = val[2] ? val[2] : ''
  263. },
  264. async hasData(){
  265. const ret = await queryPageAreaDealer({pageNo:1,pageSize:10,subareaSn: this.parentData.subareaSn, subareaAreaSn: this.parentData.subareaAreaSn}).then(res => res.data)
  266. this.flag = ret.count == 0
  267. },
  268. pageInit () {
  269. const _this = this
  270. this.$nextTick(() => { // 页面渲染完成后的回调
  271. _this.setTableH()
  272. })
  273. this.flag = true
  274. // 判断是已绑定数据
  275. this.hasData()
  276. },
  277. setTableH () {
  278. const tableSearchH = this.$refs.tableSearch.offsetHeight
  279. this.tableHeight = window.innerHeight - tableSearchH - 290
  280. }
  281. },
  282. }
  283. </script>
  284. <style lang="less">
  285. .viewsDealer{
  286. .ant-drawer-body{
  287. padding:10px 20px 0;
  288. }
  289. }
  290. .deraw-bindDealer {
  291. .ant-drawer-body{
  292. padding:10px 20px 0;
  293. }
  294. }
  295. </style>