supplierSet.vue 7.9 KB

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