linwenxin 1 gadu atpakaļ
vecāks
revīzija
66c2fc9968

+ 65 - 0
src/api/commodityManagement.js

@@ -0,0 +1,65 @@
+import request, { postBlob, getBlob, handleImport } from '@/utils/request'
+
+export function esGoodsList(data) {
+  return request({
+    url: `/es/goods/list?moduleId=${data.moduleId}`,
+    method: 'post',
+    data
+  })
+}
+
+export function esGoodsListExport(data, name) {
+  return postBlob({
+    url: '/es/goods/list/export',
+    data,
+    name
+  })
+}
+
+export function esGoodsUpdate(data) {
+  return request({
+    url: '/es/goods/update',
+    method: 'post',
+    data: data
+  })
+}
+
+export function esGoodsDetail(params) {
+  return request({
+    url: '/es/goods/detail',
+    method: 'post',
+    params
+  })
+}
+
+export function esGoodsDel(params) {
+  return request({
+    url: '/es/goods/del',
+    method: 'post',
+    params
+  })
+}
+
+export function esGoodsCopy(params) {
+  return request({
+    url: '/es/goods/copy',
+    method: 'post',
+    params
+  })
+}
+
+export function esGoodsBatchUpdateStatus(params) {
+  return request({
+    url: '/es/goods/batch/update/status',
+    method: 'post',
+    params
+  })
+}
+
+export function esGoodsTop(params) {
+  return request({
+    url: '/es/goods/top',
+    method: 'post',
+    params
+  })
+}

+ 367 - 0
src/views/secondHandMall/commodityManagement/form.vue

@@ -0,0 +1,367 @@
+<template>
+  <zj-page-container>
+    <zj-page-fill class="neibuview">
+      <zj-form-container ref="formRef" :form-data="formData" :form-rules="formRules">
+        <zj-form-module title="商品详情" :form-data="formData" :form-items="formItems" label-width="80px" :column="3">
+        </zj-form-module>
+        <zj-form-module title="出售信息" class="my-module" :form-data="formData.order" :form-items="formItems2"
+          label-width="80px" :column="3" />
+      </zj-form-container>
+    </zj-page-fill>
+    <div style="box-sizing: border-box; padding: 10px; text-align: right;">
+      <el-button type="primary" size="small" @click="handleSubmit">保存</el-button>
+      <el-button v-if="formData.id && ~['OFF'].indexOf(formData.status)" type="primary" size="small"
+        @click="copyGoods">克隆商品</el-button>
+      <el-button v-if="formData.id && ~['ON'].indexOf(formData.status)" type="primary" size="small"
+        @click="setStatus(false)">下架</el-button>
+      <el-button v-if="formData.id && ~['ON', 'SALE'].indexOf(formData.status)" type="primary" size="small"
+        @click="handleSubmit">转销售</el-button>
+      <el-button v-if="formData.id && ~['SALE'].indexOf(formData.status)" type="primary" size="small"
+        @click="setStatus(true)">重新上架</el-button>
+      <el-button size="small" @click="handleClose">取消</el-button>
+    </div>
+  </zj-page-container>
+</template>
+
+<script>
+import ImageUpload from '@/components/Common/image-upload.vue'
+import { esGoodsDetail, esGoodsCopy, esGoodsBatchUpdateStatus } from '@/api/commodityManagement'
+export default {
+  components: { ImageUpload },
+  props: {
+    detailId: {
+      type: String,
+      default: ''
+    }
+  },
+  data() {
+    return {
+      formData: {
+        "brand": "",
+        "categoryId": "",
+        "categoryName": "",
+        "companyWechatId": "",
+        "companyWechatName": "",
+        "del": true,
+        "goodsName": "",
+        "goodsNote": "",
+        "imgList": [],
+        "isTop": true,
+        "likeCount": 0,
+        "makeDate": "",
+        "mark": "",
+        "markId": "",
+        "messageList": [],
+        "operateRecordList": [],
+        "power": "",
+        "price": 0,
+        "qty": 0,
+        "queryCount": 0,
+        "remark": "",
+        "sort": 0,
+        "status": "",
+        "topTime": "",
+        "userId": ""
+      },
+      formRules: {},
+      publishStatus: [
+        { label: '下架', value: "SALE" },
+        { label: '上架', value: "ON" },
+        { label: '已卖出', value: "OFF" },
+      ],
+    }
+  },
+  computed: {
+    formItems() {
+      return [
+        {
+          name: 'el-input',
+          md: 12,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '商品分类', prop: 'categoryName' }
+        },
+        {
+          name: 'el-radio',
+          options: this.publishStatus,
+          attributes: { disabled: true },
+          md: 12,
+          formItemAttributes: { label: '发布状态', prop: 'status' }
+        },
+        {
+          name: 'el-input',
+          md: 12,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '商品名称', prop: 'goodsName' }
+        },
+        {
+          name: 'el-input',
+          md: 12,
+          attributes: { disabled: true, type: 'textarea' },
+          formItemAttributes: { label: '商品描述', prop: 'goodsNote' }
+        },
+        {
+          name: 'el-input',
+          md: 6,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '商品价格', prop: 'price' }
+        },
+        {
+          name: 'el-input',
+          md: 6,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '上架数量', prop: 'qty' }
+        },
+        {
+          name: 'el-input',
+          md: 6,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '商品品牌', prop: 'brand' }
+        },
+        {
+          name: 'el-input',
+          md: 6,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '功率(W)', prop: 'power' }
+        },
+        {
+          name: 'el-input',
+          md: 6,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '制造日期', prop: 'makeDate' }
+        },
+        {
+          name: 'el-input',
+          md: 6,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '联系电话', prop: 'linkPhone' }
+        },
+        {
+          name: 'el-input',
+          md: 6,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '点赞量', prop: 'likeCount' }
+        },
+        {
+          name: 'slot-component',
+          md: 24,
+          attributes: { disabled: true, placeholder: '' },
+          formItemAttributes: { label: '留言量', prop: '' },
+          render: (h, { props }) => {
+            return (
+              <el-input
+                value={Number(this.formData?.messageList?.length)}
+                disabled={true}
+                size="mini"
+                placeholder=""
+              ></el-input>
+            )
+          },
+        },
+        {
+          name: 'el-radio',
+          options: [
+            { label: '一级能效', value: "一级能效" },
+            { label: '二级能效', value: "二级能效" },
+            { label: '三级能效', value: "三级能效" },
+            { label: '四级能效', value: "四级能效" },
+            { label: '五级能效', value: "五级能效" },
+          ],
+          md: 24,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '能效标识', prop: 'mark' }
+        },
+        {
+          name: 'slot-component',
+          md: 24,
+          attributes: { disabled: true },
+          formItemAttributes: { label: '商品图片', prop: 'imgList' },
+          render: (h, { props }) => {
+            return (<div>
+              <ImageUpload file-list={this.formData.imgList} limit={this.formData?.imgList?.length + 1} isEdit={false} />
+            </div>)
+          }
+        },
+      ]
+    },
+    formItems2() {
+      return [{
+        name: 'slot-component',
+        md: 24,
+        attributes: { disabled: true },
+        formItemAttributes: { label: '', prop: '' },
+        render: (h, { props }) => {
+          var { formData } = props
+          console.log(formData, 999)
+          return (<div>
+            <el-row gutter={10}>
+              <el-col xs={24} sm={24} md={8} lg={8} xl={8}>
+                <div class='info'>
+                  <div class='info_title'>上架人信息</div>
+                  <div class='info_bottom'>
+                    <div class='info_bottom_lt'>
+                      <el-image
+                        style='width: 40px; height: 40px'
+                        src={this.$imageUrl + this.formData?.order?.buyerUserPic}
+                      >
+                      </el-image>
+                    </div>
+                    <div class='info_bottom_rt'>
+                      <div>微信昵称:{formData.userName}</div>
+                      <div>微信手机号:{formData.phone}</div>
+                      <div>发布时间:{formData.goodsCreateTime}</div>
+                    </div>
+                  </div>
+                </div>
+              </el-col>
+              <el-col xs={24} sm={24} md={8} lg={8} xl={8}>
+                <div class='info'>
+                  <div class='info_title'>买家信息</div>
+                  {formData.saleStatus
+                    ? <div class='info_bottom'>
+                      <div class='info_bottom_lt'>
+                        {this.formData.userPic ? <el-image
+                          style='width: 40px; height: 40px'
+                          src={this.$imageUrl + this.formData.userPic}
+                        >
+                        </el-image> : null
+                        }
+                      </div>
+                      <div class='info_bottom_rt'>
+                        <div>微信昵称:{formData.buyerUserName}</div>
+                        <div>微信手机号:{formData.buyerUserPhone}</div>
+                        <div>收货人信息:{formData.consigneeName}</div>
+                        <div>收货人地址:{formData.address}</div>
+                        <div>支付方式:{formData.payType === 'WECHAT' ? '微信支付' : ''}</div>
+                      </div>
+                    </div> : null}
+                </div>
+              </el-col>
+              <el-col xs={24} sm={24} md={8} lg={8} xl={8}>
+                <div class='info'>
+                  <div class='info_title'>物流信息</div>
+                  {formData.logisticsNum ? <div class='info_bottom'>
+                    <div class='info_bottom_rt'>
+                      <div>
+                        <el-radio-group value={formData.logisticsType}>
+                          <el-radio label='SELF'>自提</el-radio>
+                          <el-radio label='DELIVERY'>物流</el-radio>
+                        </el-radio-group>
+                      </div>
+                      <div>快递单号:{formData.logisticsNum}</div>
+                      <div>快递公司:{formData.logisticsName}</div>
+                      <el-button type='primary' size='small' onClick={() => { }}
+                      >查看物流
+                      </el-button>
+                    </div>
+                  </div> : null}
+                </div>
+              </el-col>
+            </el-row>
+          </div>)
+        }
+      }]
+    }
+  },
+  watch: {
+    detailId: {
+      handler(newVal, oldVal) {
+        if (!newVal) {
+          return
+        }
+        esGoodsDetail({ id: newVal }).then(res => {
+          console.log(res.data)
+          this.formData = {
+            ...res.data,
+            imgList: res.data.imgList.map(item => {
+              return {
+                ...item,
+                imgUrl: item.imgUrl
+              }
+            })
+          }
+        })
+      },
+      deep: true,
+      immediate: true,
+    }
+  },
+  methods: {
+    copyGoods() {
+      esGoodsCopy({ id: this.detailId.id }).then(res => {
+        this.$message({ type: 'success', message: `克隆成功!` })
+        this.handleClose()
+      })
+    },
+    setStatus(status){
+      esGoodsBatchUpdateStatus({ ids: this.detailId.id,status:status }).then(res => {
+        this.$message({ type: 'success', message: `设置成功!` })
+        this.handleClose()
+      })
+    },
+    handleSubmit() {
+
+    },
+    handleClose() {
+      this.$emit('back')
+    }
+  }
+}
+</script>
+
+<style lang="scss">
+.info {
+  .info_title {
+    font-size: 16px;
+    font-weight: 700;
+  }
+
+  .info_bottom {
+    display: flex;
+    margin: 10px 0;
+
+    .info_bottom_lt {
+      width: 40px;
+      height: 40px;
+      //background-color: rgb(136, 235, 154);
+    }
+
+    .info_bottom_rt {
+      padding: 10px 0 0 10px;
+      line-height: 30px;
+
+      .photoPZ {
+        display: inline-block;
+        vertical-align: text-top;
+      }
+    }
+  }
+}
+</style>
+<style lang="scss" scoped>
+.neibuview {
+  box-sizing: border-box;
+  padding-left: 16px;
+
+  ::v-deep &>.zj-page-fill-scroll {
+    box-sizing: border-box;
+    padding-right: 16px;
+
+    &>div:nth-child(1) {
+      margin-top: 20px;
+    }
+  }
+}
+
+.header1style {
+  text-align: right;
+  font-size: 12px;
+  color: red;
+  line-height: 18px;
+}
+
+.my-module {
+  ::v-deep .el-form-item__content {
+    margin-left: 12px !important;
+  }
+}
+</style>

+ 185 - 0
src/views/secondHandMall/commodityManagement/index.vue

@@ -0,0 +1,185 @@
+<template>
+  <template-page ref="pageRef" :get-list="getList" :export-list="exportList" :column-parsing="columnParsing"
+    :more-parameters="moreParameters" :operation="operation()" :operation-column-width="240" :replace-or-not-map="false"
+    :optionsEvensGroup="optionsEvensGroup" :tableAttributes="tableAttributes" :tableEvents="tableEvents">
+    <div class="cartographer_big">
+      <el-dialog title="编辑" width="100%" :modal="false" :visible.sync="visible" :before-close="handleClose">
+        <Form v-if="visible" :detail-id="detailId" @back="handleClose" />
+      </el-dialog>
+    </div>
+  </template-page>
+</template>
+
+<script>
+import TemplatePage from '@/components/template/template-page-1.vue'
+import import_mixin from '@/components/template/import_mixin.js'
+import operation_mixin from '@/components/template/operation_mixin.js'
+import Form from './form.vue'
+import { esGoodsList, esGoodsListExport, esGoodsDel, esGoodsTop, esGoodsBatchUpdateStatus } from '@/api/commodityManagement'
+export default {
+  components: { TemplatePage, Form },
+  mixins: [import_mixin, operation_mixin],
+  props: {},
+  data() {
+    return {
+      // 事件组合
+      optionsEvensGroup: [
+        [
+          [
+            this.optionsEvensAuth('batchListing', {
+              click: () => {
+                if (this.recordSelected.length === 0) {
+                  this.$message.warning('请勾选')
+                  return
+                }
+                esGoodsBatchUpdateStatus({
+                  ids:this.recordSelected.map(item=>item.id).join(","),
+                  status:true
+                }).then(res => {
+                  this.$message({ type: 'success', message: `设置成功!` })
+                  this.$refs.pageRef.refreshList()
+                })
+              }
+            })
+          ],
+          [
+            this.optionsEvensAuth('batchDelist', {
+              click: () => {
+                if (this.recordSelected.length === 0) {
+                  this.$message.warning('请勾选')
+                  return
+                }
+                esGoodsBatchUpdateStatus({
+                  ids:this.recordSelected.map(item=>item.id).join(","),
+                  status:false
+                }).then(res => {
+                  this.$message({ type: 'success', message: `设置成功!` })
+                  this.$refs.pageRef.refreshList()
+                })
+              }
+            })
+          ]
+        ]
+      ],
+      visible: false,
+      detailId: '',
+      // 表格属性
+      tableAttributes: {
+        // 启用勾选列
+        selectColumn: true,
+        selectable: this.selectable
+      },
+      // 表格事件
+      tableEvents: {
+        'selection-change': this.selectionChange
+      },
+      recordSelected: []
+    }
+  },
+  computed: {
+    moreParameters() {
+      return [
+        {
+          name: '状态',
+          key: 'orderType',
+          value: '',
+          conditions: [
+            {
+              label: `全部`,
+              value: ''
+            },
+            {
+              label: `上架`,
+              value: 'ON'
+            },
+            {
+              label: `下架`,
+              value: 'OFF'
+            },
+            {
+              label: `已卖出`,
+              value: 'SALE'
+            }
+          ]
+        }
+      ]
+    }
+  },
+  methods: {
+    selectable(row, index) {
+      return ["ON", "OFF"].includes(Object.entries(row.selectMapData.status).find(([key, val]) => val == row.status)?.[0])
+    },
+    // 监听勾选变化
+    selectionChange(data) {
+      this.recordSelected = data
+    },
+    // 列表请求函数
+    getList(p, cb) {
+      if (p.orderType) {
+        p.params.push({ param: 'a.status', compare: '=', value: p.orderType })
+      }
+      cb && cb(p)
+      return esGoodsList(p)
+    },
+    // 列表导出函数
+    exportList: esGoodsListExport,
+    // 表格列解析渲染数据更改
+    columnParsing(item, defaultData) {
+      return defaultData
+    },
+    operation() {
+      return this.operationBtn({
+        edit: {
+          click: ({ row, index, column }) => {
+            this.detailId = row.id
+            this.visible = true
+          }
+        },
+        del: {
+          prompt: "是否确定删除?",
+          conditions: ({ row, index, column }) => {
+            return row.status == "SALE"
+          },
+          click: ({ row, index, column }) => {
+            esGoodsDel({ id: row.id }).then(res => {
+              this.$message({ type: 'success', message: `删除成功!` })
+              this.$refs.pageRef.refreshList()
+            })
+          }
+        },
+        topFix: {
+          prompt: "是否确定置顶?",
+          conditions: ({ row, index, column }) => {
+            return !row.isTop
+          },
+          click: ({ row, index, column }) => {
+            esGoodsTop({ id: row.id, isTop: true }).then(res => {
+              this.$message({ type: 'success', message: `设置成功!` })
+              this.$refs.pageRef.refreshList()
+            })
+          }
+        },
+        unTopFix: {
+          prompt: "是否确定取消置顶?",
+          conditions: ({ row, index, column }) => {
+            return row.isTop
+          },
+          click: ({ row, index, column }) => {
+            esGoodsTop({ id: row.id, isTop: false }).then(res => {
+              this.$message({ type: 'success', message: `设置成功!` })
+              this.$refs.pageRef.refreshList()
+            })
+          }
+        }
+      })
+    },
+    handleClose() {
+      this.detailId = ''
+      this.visible = false
+      this.$refs.pageRef.refreshList()
+    }
+  }
+}
+</script>
+
+<style scoped></style>