market-list.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div class="app-container">
  3. <!-- 顶部操作区域 -->
  4. <div class="filter-container">
  5. <div class="filter-control">
  6. <span>供应商名称:</span>
  7. <el-input
  8. v-model="listQuery.shopName"
  9. placeholder="供应商名称"
  10. clearable
  11. @keyup.enter.native="getList"
  12. @clear="getList"
  13. />
  14. </div>
  15. <div class="filter-control">
  16. <el-button type="primary" @click="getList"> 查询 </el-button>
  17. <el-button type="primary" @click="shopDialogVisible = true"> 添加供应商 </el-button>
  18. </div>
  19. </div>
  20. <!-- 列表 -->
  21. <el-table v-loading="isLoading" :data="list" border style="width: 100%" height="660">
  22. <el-table-column prop="shopName" fixed label="供应商名称" align="center" />
  23. <el-table-column prop="linkMan" label="联系人" align="center" />
  24. <el-table-column prop="mobile" label="手机号" align="center">
  25. <template slot-scope="{ row }">
  26. {{ row.mobile ? row.mobile : '---' }}
  27. </template>
  28. </el-table-column>
  29. <el-table-column prop="shopStatus" label="供应商状态" align="center" width="100">
  30. <template slot-scope="{ row }">
  31. <el-tag v-if="row.shopStatus === 90" type="success" size="small">已上线</el-tag>
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="status" label="logo" align="center" width="180">
  35. <template slot-scope="{ row }">
  36. <el-popover placement="top-start" title="" width="180" trigger="hover">
  37. <img :src="row.productImage" alt="" style="width: 150px; height: 150px" />
  38. <img slot="reference" :src="row.productImage" alt="" style="width: 80px; height: 80px" />
  39. </el-popover>
  40. </template>
  41. </el-table-column>
  42. <el-table-column prop="addTime" label="最近报表时间" align="center">
  43. <template slot-scope="{ row }">
  44. {{ row.addTime ? row.addTime : '---' }}
  45. </template>
  46. </el-table-column>
  47. <el-table-column prop="addTime" label="添加时间" align="center">
  48. <template slot-scope="{ row }">
  49. {{ row.addTime ? row.addTime : '---' }}
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="操作" align="center" width="400">
  53. <template slot-scope="{ row }">
  54. <el-button type="success" size="mini" style="margin: 4px" @click="handleRecordDetail(1, row)">
  55. 上传LOGO
  56. </el-button>
  57. <el-button type="primary" size="mini" style="margin: 4px" @click="handleRecordDetail(2, row)">
  58. 数据报表
  59. </el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <!-- 页码 -->
  64. <pagination
  65. :total="total"
  66. :page-sizes="[100]"
  67. :page-size="100"
  68. :page.sync="listQuery.pageNum"
  69. :limit.sync="listQuery.pageSize"
  70. @pagination="getCustomerShopList"
  71. />
  72. <!-- 选择供应商弹窗 -->
  73. <shop-dialog v-if="shopDialogVisible" ref="shopDialog" @confirm="handleAddShopConfirm" @cancel="handleCancel" />
  74. <!-- 设置统计状态 -->
  75. <el-dialog title="设置统计状态" :visible.sync="dialogFormVisible" width="500px">
  76. <el-form ref="dataForm" :model="renewCustome" :rules="rules" label-position="right">
  77. <el-form-item prop="image" label="logo">
  78. <div class="form-el-upload" style="width: 148px; height: 148px">
  79. <el-upload
  80. class="avatar-uploader"
  81. :action="actionUrl"
  82. :headers="getToken"
  83. :show-file-list="false"
  84. :on-success="handleSuccess"
  85. :before-upload="beforeUpload"
  86. >
  87. <div v-loading="loadImgLoading" class="avatar" style="width: 148px; height: 148px; display: block">
  88. <img
  89. v-if="renewCustome.image"
  90. :src="renewCustome.image"
  91. style="width: 148px; height: 148px; display: block"
  92. @error="reloadImage"
  93. @load="loadSucess"
  94. />
  95. <i
  96. v-else
  97. class="el-icon-plus avatar-uploader-icon"
  98. style="width: 148px; height: 148px; line-height: 148px"
  99. ></i>
  100. </div>
  101. </el-upload>
  102. <p class="uploader-tips">注:请尽量上传126*50(px)尺寸的图片。</p>
  103. </div>
  104. </el-form-item>
  105. </el-form>
  106. <div slot="footer" class="dialog-footer">
  107. <el-button @click="dialogFormVisible = false">取消</el-button>
  108. <el-button type="primary" @click="handleConfirm">确定</el-button>
  109. </div>
  110. </el-dialog>
  111. </div>
  112. </template>
  113. <script>
  114. import { getCustomerShopList, saveCustomerShop, renewCustomerShop } from '@/api/user/customer/customer'
  115. import ShopDialog from './components/shop-dialog'
  116. export default {
  117. name: 'RecordList',
  118. components: { ShopDialog },
  119. filters: {},
  120. data() {
  121. return {
  122. isLoading: true,
  123. listQuery: {
  124. shopName: '',
  125. status: '',
  126. pageNum: 1,
  127. pageSize: 20
  128. },
  129. list: [],
  130. total: 0,
  131. shopDialogVisible: false,
  132. dialogFormVisible: false,
  133. renewCustome: {
  134. id: '',
  135. image: ''
  136. },
  137. rules: {
  138. image: [{ required: true, message: '请上传弹窗图片', trigger: 'blur' }]
  139. }
  140. }
  141. },
  142. computed: {
  143. etToken() {
  144. return {
  145. token: this.$store.getters.token
  146. }
  147. },
  148. actionUrl() {
  149. return process.env.VUE_APP_BASE_API + '/formData/MultiPictareaddData'
  150. }
  151. },
  152. created() {
  153. this.getList()
  154. },
  155. mounted() {},
  156. methods: {
  157. // 获取行为记录列表
  158. getList() {
  159. this.list = []
  160. this.listQuery.pageNum = 1
  161. this.getCustomerShopList()
  162. },
  163. // 确认选择供应商
  164. handleAddShopConfirm(data) {
  165. console.log('data', data)
  166. const shopIds = []
  167. data.forEach((ele) => {
  168. shopIds.push(ele.shopId)
  169. })
  170. this.saveCustomerShop({ shopIds: shopIds.join(',') })
  171. },
  172. // 取消选择供应商
  173. handleCancel() {
  174. this.shopDialogVisible = false
  175. this.$refs.shopDialog.visible = false
  176. },
  177. // 确认设置统计状态
  178. handleConfirm() {
  179. this.$refs['dataForm'].validate((valid) => {
  180. if (valid) {
  181. this.renewCustomerShop(this.renewCustome)
  182. } else {
  183. return false
  184. }
  185. })
  186. },
  187. // 获取潜客搜集供应商列表
  188. async getCustomerShopList() {
  189. try {
  190. this.isLoading = true
  191. const res = await getCustomerShopList(this.listQuery)
  192. this.list = res.data.results
  193. this.total = res.data.totalRecord
  194. this.isLoading = false
  195. } catch (error) {
  196. console.log(error)
  197. }
  198. },
  199. // 保存添加统计供应商
  200. async saveCustomerShop(params) {
  201. try {
  202. await saveCustomerShop(params)
  203. this.shopDialogVisible = false
  204. this.$message.success('操作成功')
  205. this.getList()
  206. } catch (error) {
  207. console.log(error)
  208. }
  209. },
  210. // 统计状态
  211. async renewCustomerShop(params) {
  212. try {
  213. await renewCustomerShop(params)
  214. this.dialogFormVisible = false
  215. this.$message.success('操作成功')
  216. this.getList()
  217. } catch (error) {
  218. console.log(error)
  219. }
  220. },
  221. // 查看详情
  222. handleRecordDetail(type, row) {
  223. switch (type) {
  224. case 1: // 潜客统计列表
  225. this.renewCustome.id = row.id
  226. this.renewCustome.status = row.status
  227. console.log('renewCustome', this.renewCustome)
  228. this.dialogFormVisible = true
  229. break
  230. case 2: // 相关文章
  231. this.$router.push({
  232. path: '/user/customer/market-report-list',
  233. query: { shopId: row.shopId, shopName: row.shopName }
  234. })
  235. break
  236. }
  237. },
  238. // 上传图标事件
  239. handleSuccess(res, file) {
  240. this.loadImgLoading = true
  241. this.$nextTick(() => {
  242. setTimeout(() => {
  243. this.form.image = res.data
  244. }, 1000 * 2)
  245. })
  246. },
  247. // 对上传图片的大小、格式进行限制
  248. beforeUpload(file) {
  249. const isJPG = file.type === 'image/jpeg'
  250. const isJPG2 = file.type === 'image/jpg'
  251. const isPNG = file.type === 'image/png'
  252. const isLt5M = file.size / 1024 / 1024 < 5
  253. if (!isJPG && !isJPG2 && !isPNG) {
  254. this.$message.error('只支持jpg或png格式图片')
  255. }
  256. if (!isLt5M) {
  257. this.$message.error('请上传5MB以内的图片!')
  258. }
  259. return (isJPG || isJPG2 || isPNG) && isLt5M
  260. },
  261. reloadImage() {
  262. this.loadImgLoading = true
  263. setTimeout(() => {
  264. this.temp.classifyImage = this.temp.classifyImage.split('?')[0] + '?r=' + Math.floor(Math.random() * 1000)
  265. }, 1000 * 2)
  266. },
  267. loadSucess() {
  268. this.loadImgLoading = false
  269. }
  270. }
  271. }
  272. </script>
  273. <style>
  274. .avatar-uploader .el-upload {
  275. border: 1px dashed #d9d9d9;
  276. border-radius: 6px;
  277. cursor: pointer;
  278. position: relative;
  279. overflow: hidden;
  280. float: left;
  281. }
  282. .uploader-tips {
  283. position: absolute;
  284. bottom: 0;
  285. left: 160px;
  286. line-height: 28px;
  287. color: red;
  288. margin: 0;
  289. }
  290. </style>