123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- <template>
- <div class="app-container">
- <!-- 顶部操作区域 -->
- <div class="filter-container">
- <div class="filter-control">
- <span>供应商名称:</span>
- <el-input
- v-model="listQuery.shopName"
- placeholder="供应商名称"
- clearable
- @keyup.enter.native="getList"
- @clear="getList"
- />
- </div>
- <div class="filter-control">
- <el-button type="primary" @click="getList"> 查询 </el-button>
- <el-button type="primary" @click="shopDialogVisible = true"> 添加供应商 </el-button>
- </div>
- </div>
- <!-- 列表 -->
- <el-table v-loading="isLoading" :data="list" border style="width: 100%" height="660">
- <el-table-column prop="shopName" fixed label="供应商名称" align="center" />
- <el-table-column prop="linkMan" label="联系人" align="center" />
- <el-table-column prop="mobile" label="手机号" align="center">
- <template slot-scope="{ row }">
- {{ row.mobile ? row.mobile : '---' }}
- </template>
- </el-table-column>
- <el-table-column prop="shopStatus" label="供应商状态" align="center" width="100">
- <template slot-scope="{ row }">
- <el-tag v-if="row.shopStatus === 90" type="success" size="small">已上线</el-tag>
- </template>
- </el-table-column>
- <el-table-column prop="status" label="logo" align="center" width="180">
- <template slot-scope="{ row }">
- <el-popover placement="top-start" title="" width="180" trigger="hover">
- <img :src="row.productImage" alt="" style="width: 150px; height: 150px" />
- <img slot="reference" :src="row.productImage" alt="" style="width: 80px; height: 80px" />
- </el-popover>
- </template>
- </el-table-column>
- <el-table-column prop="addTime" label="最近报表时间" align="center">
- <template slot-scope="{ row }">
- {{ row.addTime ? row.addTime : '---' }}
- </template>
- </el-table-column>
- <el-table-column prop="addTime" label="添加时间" align="center">
- <template slot-scope="{ row }">
- {{ row.addTime ? row.addTime : '---' }}
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" width="400">
- <template slot-scope="{ row }">
- <el-button type="success" size="mini" style="margin: 4px" @click="handleRecordDetail(1, row)">
- 上传LOGO
- </el-button>
- <el-button type="primary" size="mini" style="margin: 4px" @click="handleRecordDetail(2, row)">
- 数据报表
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <!-- 页码 -->
- <pagination
- :total="total"
- :page-sizes="[100]"
- :page-size="100"
- :page.sync="listQuery.pageNum"
- :limit.sync="listQuery.pageSize"
- @pagination="getCustomerShopList"
- />
- <!-- 选择供应商弹窗 -->
- <shop-dialog v-if="shopDialogVisible" ref="shopDialog" @confirm="handleAddShopConfirm" @cancel="handleCancel" />
- <!-- 设置统计状态 -->
- <el-dialog title="设置统计状态" :visible.sync="dialogFormVisible" width="500px">
- <el-form ref="dataForm" :model="renewCustome" :rules="rules" label-position="right">
- <el-form-item prop="image" label="logo">
- <div class="form-el-upload" style="width: 148px; height: 148px">
- <el-upload
- class="avatar-uploader"
- :action="actionUrl"
- :headers="getToken"
- :show-file-list="false"
- :on-success="handleSuccess"
- :before-upload="beforeUpload"
- >
- <div v-loading="loadImgLoading" class="avatar" style="width: 148px; height: 148px; display: block">
- <img
- v-if="renewCustome.image"
- :src="renewCustome.image"
- style="width: 148px; height: 148px; display: block"
- @error="reloadImage"
- @load="loadSucess"
- />
- <i
- v-else
- class="el-icon-plus avatar-uploader-icon"
- style="width: 148px; height: 148px; line-height: 148px"
- ></i>
- </div>
- </el-upload>
- <p class="uploader-tips">注:请尽量上传126*50(px)尺寸的图片。</p>
- </div>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogFormVisible = false">取消</el-button>
- <el-button type="primary" @click="handleConfirm">确定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { getCustomerShopList, saveCustomerShop, renewCustomerShop } from '@/api/user/customer/customer'
- import ShopDialog from './components/shop-dialog'
- export default {
- name: 'RecordList',
- components: { ShopDialog },
- filters: {},
- data() {
- return {
- isLoading: true,
- listQuery: {
- shopName: '',
- status: '',
- pageNum: 1,
- pageSize: 20
- },
- list: [],
- total: 0,
- shopDialogVisible: false,
- dialogFormVisible: false,
- renewCustome: {
- id: '',
- image: ''
- },
- rules: {
- image: [{ required: true, message: '请上传弹窗图片', trigger: 'blur' }]
- }
- }
- },
- computed: {
- etToken() {
- return {
- token: this.$store.getters.token
- }
- },
- actionUrl() {
- return process.env.VUE_APP_BASE_API + '/formData/MultiPictareaddData'
- }
- },
- created() {
- this.getList()
- },
- mounted() {},
- methods: {
- // 获取行为记录列表
- getList() {
- this.list = []
- this.listQuery.pageNum = 1
- this.getCustomerShopList()
- },
- // 确认选择供应商
- handleAddShopConfirm(data) {
- console.log('data', data)
- const shopIds = []
- data.forEach((ele) => {
- shopIds.push(ele.shopId)
- })
- this.saveCustomerShop({ shopIds: shopIds.join(',') })
- },
- // 取消选择供应商
- handleCancel() {
- this.shopDialogVisible = false
- this.$refs.shopDialog.visible = false
- },
- // 确认设置统计状态
- handleConfirm() {
- this.$refs['dataForm'].validate((valid) => {
- if (valid) {
- this.renewCustomerShop(this.renewCustome)
- } else {
- return false
- }
- })
- },
- // 获取潜客搜集供应商列表
- async getCustomerShopList() {
- try {
- this.isLoading = true
- const res = await getCustomerShopList(this.listQuery)
- this.list = res.data.results
- this.total = res.data.totalRecord
- this.isLoading = false
- } catch (error) {
- console.log(error)
- }
- },
- // 保存添加统计供应商
- async saveCustomerShop(params) {
- try {
- await saveCustomerShop(params)
- this.shopDialogVisible = false
- this.$message.success('操作成功')
- this.getList()
- } catch (error) {
- console.log(error)
- }
- },
- // 统计状态
- async renewCustomerShop(params) {
- try {
- await renewCustomerShop(params)
- this.dialogFormVisible = false
- this.$message.success('操作成功')
- this.getList()
- } catch (error) {
- console.log(error)
- }
- },
- // 查看详情
- handleRecordDetail(type, row) {
- switch (type) {
- case 1: // 潜客统计列表
- this.renewCustome.id = row.id
- this.renewCustome.status = row.status
- console.log('renewCustome', this.renewCustome)
- this.dialogFormVisible = true
- break
- case 2: // 相关文章
- this.$router.push({
- path: '/user/customer/market-report-list',
- query: { shopId: row.shopId, shopName: row.shopName }
- })
- break
- }
- },
- // 上传图标事件
- handleSuccess(res, file) {
- this.loadImgLoading = true
- this.$nextTick(() => {
- setTimeout(() => {
- this.form.image = res.data
- }, 1000 * 2)
- })
- },
- // 对上传图片的大小、格式进行限制
- beforeUpload(file) {
- const isJPG = file.type === 'image/jpeg'
- const isJPG2 = file.type === 'image/jpg'
- const isPNG = file.type === 'image/png'
- const isLt5M = file.size / 1024 / 1024 < 5
- if (!isJPG && !isJPG2 && !isPNG) {
- this.$message.error('只支持jpg或png格式图片')
- }
- if (!isLt5M) {
- this.$message.error('请上传5MB以内的图片!')
- }
- return (isJPG || isJPG2 || isPNG) && isLt5M
- },
- reloadImage() {
- this.loadImgLoading = true
- setTimeout(() => {
- this.temp.classifyImage = this.temp.classifyImage.split('?')[0] + '?r=' + Math.floor(Math.random() * 1000)
- }, 1000 * 2)
- },
- loadSucess() {
- this.loadImgLoading = false
- }
- }
- }
- </script>
- <style>
- .avatar-uploader .el-upload {
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
- cursor: pointer;
- position: relative;
- overflow: hidden;
- float: left;
- }
- .uploader-tips {
- position: absolute;
- bottom: 0;
- left: 160px;
- line-height: 28px;
- color: red;
- margin: 0;
- }
- </style>
|