partnerManage.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 搜索框 -->
  4. <div class="table-page-search-wrapper" style="margin-bottom: 15px;">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="48">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="商户名称"><a-input allowClear v-model.trim="queryParam.name" :maxLength="30" placeholder="请输入" id="OperateJournal-name"/></a-form-item>
  9. </a-col>
  10. <a-col :md="6" :sm="24">
  11. <a-form-item label="负责人电话"><a-input allowClear v-model.trim="queryParam.contactPhone" :maxLength="30" placeholder="请输入" id="OperateJournal-name"/></a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-button style="margin-right: 10px;" type="primary" @click="$refs.table.refresh(true)" id="OperateJournal-refreshTable">查询</a-button>
  15. <a-button type="" @click="resetForm" id="OperateJournal-resetForm">重置</a-button>
  16. </a-col>
  17. </a-row>
  18. </a-form>
  19. </div>
  20. <div class="add"><a-button
  21. type="primary"
  22. icon="plus"
  23. class="addBtn"
  24. @click="showModal"
  25. id="bannerSetting-showModal"
  26. v-hasPermission="'B_partnerManage_add'">新增</a-button></div>
  27. <!-- table列表 -->
  28. <s-table
  29. ref="table"
  30. size="default"
  31. :rowKey="(record) => record.id"
  32. :columns="columns"
  33. :data="loadData"
  34. bordered>
  35. <span slot="action" slot-scope="text, record">
  36. <a-icon
  37. v-if="$hasPermissions('B_partnerManage_edit') && record.state==0"
  38. type="edit"
  39. id="bannerSetting-handleEdit"
  40. title="编辑"
  41. class="actionBtn icon-blues"
  42. @click="handleEdit(record)" />
  43. <a-icon type="qrcode" title="查看小程序码" @click="getQrCode(record)" :style="{ fontSize: '20px', color: '#e29e14', padding: '0 10px' }" v-hasPermission="'B_partnerManage_QRcode'" />
  44. <span v-if="!$hasPermissions('B_partnerManage_edit') && (!$hasPermissions('B_partnerManage_QRcode') && record.state==0)">--</span>
  45. </span>
  46. <span slot="state" slot-scope="text, record">
  47. <a-switch
  48. v-hasPermission="'B_partnerManage_enable'"
  49. checkedChildren="启用"
  50. unCheckedChildren="禁用"
  51. id="bannerSetting-changeFlagHandle"
  52. :checked="record.state == 1 ? true : false"
  53. @change="changeFlagHandle(text, record)"
  54. />
  55. <span v-if="!$hasPermissions('B_partnerManage_enable')">--</span>
  56. </span>
  57. </s-table>
  58. <!-- 新增编辑弹窗 -->
  59. <add-partner-modal :itemId="itemId" :itemData="itemData" :openSupplierModal="openSupplierModal" @refresh="$refs.table.refresh(true)" @close="cancel"></add-partner-modal>
  60. <!-- 查看小程序码 -->
  61. <a-modal
  62. class="qrCodeModal"
  63. title="查看小程序码"
  64. :width="500"
  65. :footer="null"
  66. :destroyOnClose="true"
  67. @cancel="isQrCodeModal = false"
  68. v-model="isQrCodeModal">
  69. <img :src="qrCode" width="400" height="400" class="qrCode" />
  70. <a-button type="primary" class="downQrCode" @click="downloadCode">下载小程序码</a-button>
  71. </a-modal>
  72. </a-card>
  73. </template>
  74. <script>
  75. import moment from 'moment'
  76. import { Upload, STable, VSelect } from '@/components'
  77. import { getSellerList, changeSellerStatus, sellerQrCode } from '@/api/businessManage.js'
  78. import addPartnerModal from './addPartnerModal.vue'
  79. export default {
  80. components: {
  81. STable,
  82. Upload,
  83. VSelect,
  84. addPartnerModal
  85. },
  86. data () {
  87. return {
  88. queryParam: {
  89. name: '',
  90. contactPhone: ''
  91. },
  92. openSupplierModal: false, // 默认关闭弹窗
  93. isQrCodeModal: false, // 查看小程序码 弹框展示状态
  94. qrCode: '',
  95. itemId: null, // 编辑行id
  96. itemData: {}, // 编辑行数据
  97. // 表头
  98. columns: [
  99. {
  100. title: '序号',
  101. dataIndex: 'no',
  102. width: 60,
  103. align: 'center'
  104. },
  105. {
  106. title: '创建时间',
  107. width: 200,
  108. dataIndex: 'createDate',
  109. align: 'center'
  110. },
  111. {
  112. title: '商户名称',
  113. width: 100,
  114. dataIndex: 'name',
  115. align: 'center'
  116. },
  117. {
  118. title: '负责人',
  119. width: 100,
  120. dataIndex: 'contactName',
  121. align: 'center'
  122. },
  123. {
  124. title: '负责人电话',
  125. width: 100,
  126. dataIndex: 'contactPhone',
  127. align: 'center',
  128. scopedSlots: {
  129. customRender: 'position'
  130. }
  131. },
  132. {
  133. title: '状态',
  134. width: 100,
  135. dataIndex: 'state',
  136. align: 'center',
  137. scopedSlots: {
  138. customRender: 'state'
  139. }
  140. },
  141. {
  142. title: '操作',
  143. align: 'center',
  144. width: 100,
  145. scopedSlots: {
  146. customRender: 'action'
  147. }
  148. }
  149. ],
  150. // 加载数据方法 必须为 Promise 对象
  151. loadData: parameter => {
  152. const searchData = Object.assign(parameter, this.queryParam)
  153. console.log(this.queryOrderDate, 'this.queryOrderDate')
  154. // if (this.queryOrderDate && this.queryOrderDate.length) {
  155. // searchData.beginDate = moment(this.queryOrderDate[0]).format('YYYY-MM-DD')
  156. // searchData.endDate = moment(this.queryOrderDate[1]).format('YYYY-MM-DD')
  157. // } else {
  158. // searchData.beginDate = ''
  159. // searchData.endDate = ''
  160. // }
  161. return getSellerList(
  162. searchData
  163. ).then(res => {
  164. const no = (res.data.pageNo - 1) * res.data.pageSize
  165. if (res.status == 200) {
  166. for (let i = 0; i < res.data.list.length; i++) {
  167. const _item = res.data.list[i]
  168. _item.no = no + i + 1
  169. }
  170. return res.data
  171. }
  172. })
  173. },
  174. formLayout: 'horizontal',
  175. hideRequiredMark: false, // 是否显示必填的* 默认显示
  176. form: this.$form.createForm(this),
  177. formItemLayout: {
  178. labelCol: {
  179. span: 6
  180. },
  181. wrapperCol: {
  182. span: 14
  183. }
  184. }
  185. }
  186. },
  187. methods: {
  188. // 禁止不可选日期
  189. // disabledDate (current) {
  190. // return current && current > moment().endOf('day')
  191. // },
  192. showModal () {
  193. this.itemId = null
  194. this.itemData = {}
  195. this.openSupplierModal = true
  196. },
  197. // 编辑
  198. handleEdit (record) {
  199. this.itemId = record.id
  200. this.itemData = record
  201. console.log(this.itemId, '-------编辑')
  202. this.openSupplierModal = true
  203. },
  204. cancel () {
  205. this.itemId = null
  206. this.openSupplierModal = false
  207. },
  208. // 重置
  209. resetForm () {
  210. // this.queryOrderDate = undefined
  211. this.queryParam.name = ''
  212. // this.queryParam.beginDate = ''
  213. // this.queryParam.endDate = ''
  214. this.queryParam.contactPhone = ''
  215. this.$refs.table.refresh(true)
  216. },
  217. // 更改启用禁用状态
  218. changeFlagHandle (text, record) {
  219. console.log(text)
  220. const _this = this
  221. const _data = {
  222. id: record.id,
  223. flag: record.state == 1 ? '0' : '1'
  224. }
  225. changeSellerStatus(_data).then(res => {
  226. if (res.status == 200) {
  227. _this.$message.success(res.message)
  228. _this.$refs.table.refresh()
  229. } else {
  230. record.state = !record.state
  231. }
  232. })
  233. },
  234. // 查看小程序码
  235. getQrCode (item) {
  236. sellerQrCode({ officialPartnerNo: item.officialPartnerNo }).then(res => {
  237. if (res.status == 200) {
  238. this.qrCode = 'data:image/png;base64,' + res.data
  239. this.isQrCodeModal = true
  240. } else {
  241. this.qrCode = ''
  242. }
  243. })
  244. },
  245. // 下载小程序码
  246. downloadCode () {
  247. const link = document.createElement('a')
  248. link.href = this.qrCode
  249. link.download = 'qrCode.png'
  250. link.click()
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="less" scoped>
  256. .addBtn {
  257. margin-bottom: 20px;
  258. }
  259. // 查看小程序码 弹框
  260. .qrCodeModal {
  261. .qrCode {
  262. display: block;
  263. max-width: 100%;
  264. margin: 0 auto;
  265. }
  266. .downQrCode {
  267. display: block;
  268. margin: 40px auto 30px;
  269. }
  270. }
  271. </style>