| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <template>
- <wrapper
- fill
- margin
- padding
- background
- >
- <schema-table
- ref="table"
- :schema="schema"
- />
- <merchant-dialog
- ref="addDialog"
- @done="onAdded"
- />
- <confirm-dialog
- ref="uploadDialog"
- title="新增导入文件"
- @confirm="onUpload"
- >
- <el-upload
- ref="upload"
- class="o-upload l-flex__auto"
- action="none"
- :auto-upload="false"
- :show-file-list="false"
- :on-change="onChange"
- drag
- >
- <div class="l-flex--row">
- <i class="o-upload__icon el-icon-upload" />
- <template v-if="upload.file">
- <div class="u-color--blue">
- {{ upload.file.name }}
- </div>
- </template>
- <template v-else>
- <span class="c-sibling-item">
- 拖拽文件到此或
- </span>
- <span class="c-sibling-item near u-color--blue">
- 点击选择文件
- </span>
- </template>
- </div>
- </el-upload>
- </confirm-dialog>
- <el-dialog
- :visible.sync="showProgress"
- custom-class="c-dialog--transparent"
- :close-on-click-modal="false"
- :close-on-press-escape="false"
- >
- <el-progress
- class="u-align-self--stretch"
- :percentage="progress"
- :stroke-width="24"
- text-inside
- status="success"
- />
- </el-dialog>
- </wrapper>
- </template>
- <script>
- import {
- getMerchantsByQuery,
- deleteMerchant,
- uploadMerchant
- } from '@/api/merchant.js'
- import MerchantDialog from './components/MerchantDialog.vue'
- export default {
- components: {
- MerchantDialog
- },
- data () {
- return {
- upload: {},
- showProgress: false,
- progress: 0
- }
- },
- computed: {
- schema () {
- return {
- props: {
- size: 'small'
- },
- list: getMerchantsByQuery,
- buttons: [
- { type: 'add', on: this.addStreamingMedia },
- { type: 'add', label: '上传', on: this.uploadStreamingMedia }
- ],
- filters: [
- { key: 'name', type: 'search', placeholder: '门店名称' },
- { key: 'personName', type: 'search', placeholder: '门店负责人' },
- { type: 'refresh' }
- ],
- cols: [
- { prop: 'name', label: '门店名称' },
- { prop: 'personName', label: '门店负责人', width: 100, align: 'center' },
- { prop: 'personPhone', label: '负责人手机号', width: 100, align: 'center' },
- { prop: 'cityName', label: '城市名称' },
- { prop: 'countyName', label: '区县名称' },
- { prop: 'address', label: '详细地址' },
- { prop: 'region', label: '省区' },
- { prop: 'serviceName', label: '服务商' },
- { prop: 'servicePerson', label: '服务商联系人', width: 100, align: 'center' },
- { prop: 'servicePhone', label: '服务商电话', width: 100, align: 'center' },
- { label: '门店认证状态', type: 'tag', render: ({ authStatus }) => authStatus
- ? {
- type: 'danger',
- label: '未认证'
- }
- : {
- type: 'success',
- label: '已认证'
- }, size: 'sm', width: 92 },
- { label: '中通有投门店', type: 'tag', render: ({ status }) => status
- ? {
- type: 'danger',
- label: '否'
- }
- : {
- type: 'success',
- label: '是'
- }, size: 'sm', width: 92 },
- { type: 'invoke', render: [
- { label: '编辑', on: this.onView },
- { label: '删除', on: this.onDel }
- ], width: 100 }
- ]
- }
- }
- },
- methods: {
- onView (asset) {
- this.$refs.addDialog.show(asset)
- },
- onDel (asset) {
- deleteMerchant(asset).then(() => {
- this.$refs.table.decrease(1)
- })
- },
- addStreamingMedia () {
- this.$refs.addDialog.show()
- },
- uploadStreamingMedia () {
- this.upload = {
- file: null
- }
- this.$refs.uploadDialog.show()
- },
- onUpload (done) {
- if (!this.upload.file) {
- this.$message({
- type: 'warning',
- message: '请选择升级APK'
- })
- return
- }
- const formData = new FormData()
- const { file } = this.upload
- console.log(file)
- formData.append('upload-file', file)
- this.progress = 0
- this.showProgress = true
- uploadMerchant(formData, ({ loaded, total }) => {
- this.progress = Math.min(99, loaded * 100 / total | 0)
- }).finally(() => {
- this.progress = 100
- this.showProgress = false
- }).then(() => {
- done()
- this.$refs.table.resetCondition()
- })
- },
- onChange ({ raw }) {
- this.$refs.upload.clearFiles()
- this.upload.file = raw
- },
- onAdded (streamingMedia) {
- this.$refs.table.resetCondition(streamingMedia)
- }
- }
- }
- </script>
|