supplierSet.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="supplierSet-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <div class="supplierSetCon-wrap">
  5. <!-- 操作按钮 -->
  6. <div class="table-page-search-wrapper flex-center" style="width:100%;justify-content: space-between;margin-bottom:10px">
  7. <div class="supplierSet-btnGroup">
  8. <a-button type="primary" id="supplierSet-add" @click="openSupplierModal">新增</a-button>
  9. </div>
  10. <!-- 搜索条件 -->
  11. <div>
  12. <a-form layout="inline" id="supplierSet-form" @keyup.enter.native="$refs.table.refresh(true)">
  13. <a-input style="width:300px;" id="supplierSet-dealerName" v-model.trim="queryParam.supplierName" allowClear placeholder="请输入供应商名称"/>
  14. <a-button style="margin-left: 15px" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="supplierSet-refresh">查询</a-button>
  15. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="supplierSet-reset">重置</a-button>
  16. </a-form>
  17. </div>
  18. </div>
  19. <a-spin :spinning="spinning" tip="Loading...">
  20. <!-- 列表 -->
  21. <s-table
  22. class="sTable fixPagination"
  23. ref="table"
  24. size="small"
  25. :rowKey="(record) => record.id"
  26. :columns="columns"
  27. :data="loadData"
  28. :defaultLoadData="false"
  29. :style="{ height: tableHeight + 70 +'px' }"
  30. :scroll="{ y: tableHeight }"
  31. bordered>
  32. <!-- 操作 -->
  33. <template slot="action" slot-scope="text, record">
  34. <a-button
  35. size="small"
  36. type="link"
  37. :id="'supplierSet-del-btn'+record.id"
  38. class="button-error"
  39. @click="handleDel(record)"
  40. >
  41. 删除
  42. </a-button>
  43. </template>
  44. </s-table>
  45. </a-spin>
  46. </div>
  47. </a-spin>
  48. <!-- 选择供应商 -->
  49. <a-drawer
  50. title="选择供应商"
  51. width="80%"
  52. :zIndex="100"
  53. :visible="openChooseSupplier"
  54. :get-container="false"
  55. :wrap-style="{ position: 'absolute' }"
  56. @close="openChooseSupplier = false">
  57. <div class="dealerModalCon">
  58. <chooseSupplier ref="supplierChoose" @plAdd="handleAddSupplier"></chooseSupplier>
  59. </div>
  60. </a-drawer>
  61. </div>
  62. </template>
  63. <script>
  64. import { commonMixin } from '@/utils/mixin'
  65. // 组件
  66. import { STable } from '@/components'
  67. import chooseSupplier from './chooseSupplier.vue'
  68. // 接口
  69. import { querySupplierScopePage, querySupplierScope, saveSupplierList, bizuserScopeDelete } from '@/api/bizuser'
  70. export default {
  71. name: 'SupplierSet',
  72. mixins: [commonMixin],
  73. components: { chooseSupplier, STable },
  74. props: {
  75. bizUserSn: {
  76. type: String,
  77. default: ''
  78. }
  79. },
  80. data () {
  81. return {
  82. spinning: false,
  83. tableHeight: 0, // 表格高度
  84. disabled: false, // 查询、重置按钮是否可操作
  85. columns: [
  86. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  87. { title: '添加时间', dataIndex: 'createDate', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  88. { title: '供应商名称', dataIndex: 'supplier.supplierName', width: '60%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  89. // { title: '联系人', dataIndex: 'subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  90. // { title: '联系手机', dataIndex: 'subareaAreaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  92. ],
  93. openChooseSupplier: false, // 选择供应商弹窗
  94. // 查询参数
  95. queryParam: {
  96. supplierName: ''// 供应商名称
  97. },
  98. dataSource: [], // 列表数据
  99. // 加载数据方法 必须为 Promise 对象
  100. loadData: parameter => {
  101. this.disabled = true
  102. this.spinning = true
  103. this.queryParam.userSn = this.$route.query.sn
  104. this.queryParam.bizUserSn = this.bizUserSn
  105. // 获取列表数据 有分页
  106. return querySupplierScopePage(Object.assign(parameter, this.queryParam)).then(res => {
  107. let data
  108. data = res.data
  109. // 计算列表序号
  110. const no = (data.pageNo - 1) * data.pageSize
  111. this.total = data.count || 0
  112. for (var i = 0; i < data.list.length; i++) {
  113. data.list[i].no = no + i + 1
  114. }
  115. this.dataSource = data.list
  116. this.disabled = false
  117. this.spinning = false
  118. return data
  119. })
  120. }
  121. }
  122. },
  123. methods: {
  124. // 打开供应商弹窗
  125. async openSupplierModal () {
  126. const _this = this
  127. const arr = []
  128. const dataList = await querySupplierScope({ userSn: this.$route.query.sn })
  129. if (dataList.data && dataList.data.length > 0) {
  130. dataList.data.forEach(con => {
  131. arr.push(con.bizSn)
  132. })
  133. _this.chooseInfo = [...new Set(arr)]
  134. } else {
  135. _this.chooseInfo = []
  136. }
  137. const dataInfo = {
  138. list: _this.chooseInfo,
  139. sn: _this.$route.query.sn
  140. }
  141. this.openChooseSupplier = true
  142. this.$nextTick(() => {
  143. _this.$refs.supplierChoose.pageInit(dataInfo)
  144. })
  145. },
  146. // 选择供应商
  147. handleAddSupplier (list) {
  148. const newData = [] list.forEach(con => { const obj = {}
  149. obj.userSn = this.$route.query.sn
  150. obj.bizUserSn = this.bizUserSn obj.bizType = 'supplier' obj.bizSn = con newData.push(obj) }) this.saveChooseDealer(newData)
  151. },
  152. // 保存所选供应商
  153. saveChooseDealer (list) {
  154. const _this = this
  155. const ajaxData = {}
  156. ajaxData.userSn = _this.$route.query.sn
  157. ajaxData.bizUserScopeList = list
  158. saveSupplierList(ajaxData).then(res => {
  159. if (res.status == 200) {
  160. _this.openChooseSupplier = false
  161. _this.resetSearchForm()
  162. }
  163. })
  164. },
  165. // 删除供应商
  166. handleDel (row) {
  167. const _this = this
  168. this.$confirm({
  169. title: '提示',
  170. content: '确认要删除吗?删除后当前用户权限以最新权限为准',
  171. centered: true,
  172. onOk () {
  173. bizuserScopeDelete({ id: row.bizUserScopeSn }).then(res => {
  174. if (res.status == 200) {
  175. _this.resetSearchForm()
  176. }
  177. })
  178. }
  179. })
  180. },
  181. // 重置
  182. resetSearchForm () {
  183. this.queryParam = {
  184. supplierName: ''
  185. }
  186. this.$refs.table.refresh(true)
  187. },
  188. // 初始化
  189. pageInit () {
  190. const _this = this
  191. this.$nextTick(() => { // 页面渲染完成后的回调
  192. _this.setTableH()
  193. })
  194. this.$refs.table.refresh()
  195. },
  196. // 计算表格高度
  197. setTableH () {
  198. this.tableHeight = window.innerHeight - 345
  199. }
  200. },
  201. watch: {
  202. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  203. this.setTableH()
  204. }
  205. },
  206. beforeRouteEnter (to, from, next) {
  207. next(vm => {})
  208. }
  209. }
  210. </script>
  211. <style lang="less">
  212. .supplierSet-wrap{
  213. }
  214. </style>