partnerManage.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <a-card :bordered="false" class="partnerManage-page-info">
  3. <!-- 搜索框 -->
  4. <div class="partnerManage-search">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="20">
  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' }" />
  44. <!-- <span v-if="!($hasPermissions('B_partnerManage_edit') && record.state==0) && !$hasPermissions('B_partnerManage_QRcode') ">--</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. :shName="shName"
  67. :destroyOnClose="true"
  68. @cancel="isQrCodeModal = false"
  69. v-model="isQrCodeModal">
  70. <img :src="qrCode" width="400" height="400" class="qrCode" />
  71. <a-button type="primary" class="downQrCode" @click="downloadCode">下载二维码</a-button>
  72. <!-- <a-button type="primary" class="downQrCode" @click="downloadCode">下载小程序码</a-button> -->
  73. </a-modal>
  74. </a-card>
  75. </template>
  76. <script>
  77. import { Upload, STable, VSelect } from '@/components'
  78. import { getSellerList, changeSellerStatus } from '@/api/businessManage.js'
  79. import addPartnerModal from './addPartnerModal.vue'
  80. import QRCode from 'qrcode'
  81. export default {
  82. components: {
  83. STable,
  84. Upload,
  85. VSelect,
  86. addPartnerModal
  87. },
  88. data () {
  89. return {
  90. queryParam: {
  91. name: '',
  92. contactPhone: ''
  93. },
  94. openSupplierModal: false, // 默认关闭弹窗
  95. isQrCodeModal: false, // 查看小程序码 弹框展示状态
  96. qrCode: '',
  97. itemId: null, // 编辑行id
  98. itemData: {}, // 编辑行数据
  99. shName: '', // 商户名称
  100. // 表头
  101. columns: [
  102. {
  103. title: '序号',
  104. dataIndex: 'no',
  105. width: 60,
  106. align: 'center'
  107. },
  108. {
  109. title: '创建时间',
  110. width: 200,
  111. dataIndex: 'createDate',
  112. align: 'center'
  113. },
  114. {
  115. title: '商户名称',
  116. width: 100,
  117. dataIndex: 'name',
  118. align: 'center'
  119. },
  120. {
  121. title: '负责人',
  122. width: 100,
  123. dataIndex: 'contactName',
  124. align: 'center'
  125. },
  126. {
  127. title: '负责人电话',
  128. width: 100,
  129. dataIndex: 'contactPhone',
  130. align: 'center',
  131. scopedSlots: {
  132. customRender: 'position'
  133. }
  134. },
  135. {
  136. title: '状态',
  137. width: 100,
  138. dataIndex: 'state',
  139. align: 'center',
  140. scopedSlots: {
  141. customRender: 'state'
  142. }
  143. },
  144. {
  145. title: '操作',
  146. align: 'center',
  147. width: 100,
  148. scopedSlots: {
  149. customRender: 'action'
  150. }
  151. }
  152. ],
  153. // 加载数据方法 必须为 Promise 对象
  154. loadData: parameter => {
  155. const searchData = Object.assign(parameter, this.queryParam)
  156. console.log(this.queryOrderDate, 'this.queryOrderDate')
  157. return getSellerList(
  158. searchData
  159. ).then(res => {
  160. const no = (res.data.pageNo - 1) * res.data.pageSize
  161. if (res.status == 200) {
  162. for (let i = 0; i < res.data.list.length; i++) {
  163. const _item = res.data.list[i]
  164. _item.no = no + i + 1
  165. }
  166. return res.data
  167. }
  168. })
  169. },
  170. formLayout: 'horizontal',
  171. hideRequiredMark: false, // 是否显示必填的* 默认显示
  172. form: this.$form.createForm(this),
  173. formItemLayout: {
  174. labelCol: {
  175. span: 6
  176. },
  177. wrapperCol: {
  178. span: 14
  179. }
  180. }
  181. }
  182. },
  183. methods: {
  184. showModal () {
  185. this.itemId = null
  186. this.itemData = {}
  187. this.openSupplierModal = true
  188. },
  189. // 编辑
  190. handleEdit (record) {
  191. this.itemId = record.id
  192. this.itemData = record
  193. this.openSupplierModal = true
  194. },
  195. cancel () {
  196. this.itemId = null
  197. this.openSupplierModal = false
  198. },
  199. // 重置
  200. resetForm () {
  201. this.queryParam.name = ''
  202. this.queryParam.contactPhone = ''
  203. this.$refs.table.refresh(true)
  204. },
  205. // 更改启用禁用状态
  206. changeFlagHandle (text, record) {
  207. console.log(text)
  208. const _this = this
  209. const _data = {
  210. id: record.id,
  211. flag: record.state == 1 ? '0' : '1'
  212. }
  213. changeSellerStatus(_data).then(res => {
  214. if (res.status == 200) {
  215. _this.$message.success(res.message)
  216. _this.$refs.table.refresh()
  217. } else {
  218. record.state = !record.state
  219. }
  220. })
  221. },
  222. // 查看二维码
  223. getQrCode (item) {
  224. const _this = this
  225. const opts = {
  226. errorCorrectionLevel: 'H',
  227. type: 'image/jpeg',
  228. quality: 0.3,
  229. margin: 1.5,
  230. width: 240,
  231. color: {
  232. dark: '#000000',
  233. light: '#ffffff'
  234. }
  235. }
  236. const url = 'officialPartnerNo=' + item.encryptedPartnerNo + '&codeType=hexiao'
  237. _this.shName = item.name
  238. console.log(item.encryptedPartnerNo)
  239. if (url) {
  240. QRCode.toDataURL(url, opts, function (err, url) {
  241. _this.qrCode = url
  242. _this.isQrCodeModal = true
  243. })
  244. }
  245. },
  246. // 查看小程序码
  247. // getQrCode (item) {
  248. // sellerQrCode({ officialPartnerNo: item.officialPartnerNo }).then(res => {
  249. // if (res.status == 200) {
  250. // this.qrCode = 'data:image/png;base64,' + res.data
  251. // this.isQrCodeModal = true
  252. // } else {
  253. // this.qrCode = ''
  254. // }
  255. // })
  256. // },
  257. // 下载二维码
  258. downloadCode (item) {
  259. const link = document.createElement('a')
  260. link.href = this.qrCode
  261. link.download = this.shName + '.png'
  262. link.click()
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="less" scoped>
  268. .partnerManage-page-info{
  269. .partnerManage-search{
  270. margin-bottom: 15px;
  271. }
  272. .addBtn {
  273. margin-bottom: 15px;
  274. }
  275. }
  276. // 查看小程序码 弹框
  277. .qrCodeModal {
  278. .qrCode {
  279. display: block;
  280. max-width: 100%;
  281. margin: 0 auto;
  282. }
  283. .downQrCode {
  284. display: block;
  285. margin: 40px auto 30px;
  286. }
  287. }
  288. </style>