Browse Source

始宁农业管理后台:农产品管理-农产品管理

panyong 2 years ago
parent
commit
5027a1d451

+ 0 - 1
htmldev/shiningManage/src/store/modules/common.js

@@ -156,7 +156,6 @@ const actions = {
   },
   // 商品分类
   async setCategoryList({ commit }) {
-    console.log(fetch)
     const data = await fetch('/api/shop/product/category/list', {})
     if (data.code === 200) {
       const temp = data.data.map(item => {

+ 1 - 1
htmldev/shiningManage/src/views/productManage/products/details.vue

@@ -121,7 +121,7 @@
             <el-option
               :label="item.name"
               :value="item.value"
-              v-for="item in arrCategoryList"
+              v-for="item in arrBrandList"
               :key="item.value"></el-option>
           </el-select>
         </el-form-item>

+ 18 - 2
htmldev/shiningManage/src/views/productManage/products/index.vue

@@ -90,8 +90,9 @@
       </el-table-column>
       <el-table-column label="创建时间" prop="product_check_at" min-width="160"></el-table-column>
       <!-- todo 缺编辑接口 -->
-      <el-table-column label="操作">
+      <el-table-column label="操作" width="120">
         <template slot-scope="scope">
+          <el-button type="text" @click="del(scope.row)">推荐</el-button>
           <el-button type="text" @click="edit(scope.row)">操作</el-button>
         </template>
       </el-table-column>
@@ -127,7 +128,7 @@ export default {
   data() {
     return {
       detailsDialog: {
-        show: true,
+        show: false,
         exData: {}
       },
       time: [],
@@ -155,6 +156,21 @@ export default {
       this.detailsDialog.exData = row
       this.detailsDialog.show = true
     },
+    del(row) {
+      this.$confirm('确定要推荐吗', '确认', {
+        type: 'warning'
+      }).then(async () => {
+        const data = await this.$fetch('/api/admin/good/product/recomend', {
+          id: row.id,
+          type: 1 // 类型(1推荐2取消推荐)
+        })
+        if (data.code === 200) {
+          this.$message.success('推荐成功')
+          this.init()
+        }
+      }).catch(() => {
+      })
+    },
     getProductStatusText(val) {
       const index = this.arrProductStatus.findIndex(item => item.value === val)
       if (index > -1) {

+ 115 - 4
htmldev/shiningManage/src/views/productManage/recommend/details.vue

@@ -1,13 +1,124 @@
 <template>
-  <div></div>
+  <div>
+    <el-dialog
+      :title="exData.id ? '编辑': ''"
+      :visible.sync="dialog"
+      width="800px"
+      :close-on-click-modal="false"
+      top="50px">
+      <el-form
+        ref="form"
+        :rules="formRules"
+        :model="form"
+        label-width="80px">
+        <el-form-item
+          v-for="(item, index) in form.product_recommend_lable"
+          :label="'标签' + (index + 1) + ':'"
+          :key="item.key"
+          :prop="'product_recommend_lable.' + index + '.value'"
+          :rules="formRules.required">
+          <el-input
+            style="width: 90%;"
+            v-model="item.value"></el-input>
+          <el-button
+            style="margin-left:20px;padding: 0;font-size: 20px;"
+            type="text"
+            class="el-icon-delete"
+            @click.prevent="removeDomain(item)">
+          </el-button>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" style="text-align: center">
+        <el-button
+          @click="dialog = false">取 消
+        </el-button>
+        <el-button @click="addDomain">新增标签</el-button>
+        <el-button
+          type="primary"
+          @click="handleSubmit"
+          :disabled="booLock">保存
+        </el-button>
+      </div>
+    </el-dialog>
+  </div>
 </template>
 
 <script>
 export default {
-  name: 'details'
+  props: {
+    value: {
+      type: Boolean,
+      default: true
+    },
+    exData: {
+      type: Object,
+      default: function () {
+        return {}
+      }
+    }
+  },
+  data() {
+    return {
+      dialog: !!this.value,
+      form: {
+        product_recommend_lable: [
+          {
+            value: ''
+          }
+        ]
+      },
+      booLock: false
+    }
+  },
+  methods: {
+    removeDomain(item) {
+      const index = this.form.product_recommend_lable.indexOf(item)
+      if (index !== -1) {
+        this.form.product_recommend_lable.splice(index, 1)
+      }
+    },
+    addDomain() {
+      this.form.product_recommend_lable.push({
+        value: '',
+        key: Date.now()
+      })
+    },
+    async handleSubmit() {
+      this.$refs.form.validate(async valid => {
+        if (valid) {
+          const postData = {
+            ...this.form,
+            product_recommend_lable: this.form.product_recommend_lable.map(item => item.value)
+          }
+          this.booLock = true
+          const data = await this.$fetch('/api/admin/good/product/lable', postData)
+          if (data.code === 200) {
+            this.dialog = false
+            this.$message.success('编辑成功')
+            this.$emit('success')
+          }
+          this.booLock = false
+        }
+      })
+    }
+  },
+  mounted() {
+    if (this.exData.id) {
+      this.$set(this.form, 'id', this.exData.id)
+    }
+  },
+  watch: {
+    dialog(val) {
+      if (!val) this.$emit('input', val)
+    }
+  }
 }
 </script>
 
-<style scoped>
-
+<style lang="scss" scoped>
+.hide-el-upload {
+  ::v-deep .el-upload--picture-card {
+    visibility: hidden;
+  }
+}
 </style>

+ 172 - 4
htmldev/shiningManage/src/views/productManage/recommend/index.vue

@@ -1,13 +1,181 @@
 <template>
-  <div></div>
+  <div class="padding-20">
+    <div class="search-box">
+      <el-form ref="form" :inline="true" :model="searchForm" clearable label-width="100px" class="mt-10">
+        <el-form-item label="农户编号:">
+          <el-input v-model="searchForm.user_id" placeholder="请输入农户编号" clearable></el-input>
+        </el-form-item>
+        <el-form-item label="农户姓名:">
+          <el-input v-model="searchForm.user_name" placeholder="请输入农户姓名" clearable></el-input>
+        </el-form-item>
+        <el-form-item label="农产品名字:">
+          <el-input v-model="searchForm.product_title" placeholder="请输入农产品名字" clearable></el-input>
+        </el-form-item>
+        <el-form-item label="类型:">
+          <el-select
+            clearable
+            placeholder="请选择类型"
+            v-model="searchForm.type">
+            <el-option
+              :label="item.name"
+              :value="item.value"
+              v-for="item in arrProductSaleType"
+              :key="item.value"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="状态:">
+          <el-select
+            clearable
+            placeholder="请选择状态"
+            v-model="searchForm.product_status">
+            <el-option
+              :label="item.name"
+              :value="item.value"
+              v-for="item in arrProductStatus"
+              :key="item.value"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item class="ml-10">
+          <el-button icon="el-icon-search" type="primary" @click="searchSubmit">查询</el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+    <el-table
+      :data="tableData"
+      stripe
+      v-loading="tableLoading"
+      fit
+      class="marginT-10 order-table"
+      border
+      :max-height="vheight">
+      <el-table-column label="商品货号" prop="product_code" min-width="140"></el-table-column>
+      <el-table-column label="农产品名字" prop="product_title" min-width="200" show-overflow-tooltip></el-table-column>
+      <el-table-column label="农产品描述" prop="product_desc" min-width="200" show-overflow-tooltip></el-table-column>
+      <el-table-column label="商品主图" prop="product_img_url" min-width="100">
+        <template slot-scope="scope">
+          <el-image
+            style="display:block;width: 80px; height: 80px;font-size: 0;"
+            :src="scope.row.product_img_url"
+            :preview-src-list="[scope.row.product_img_url]">
+          </el-image>
+        </template>
+      </el-table-column>
+      <el-table-column label="分类" prop="product_category_name"></el-table-column>
+      <el-table-column label="商品品牌" prop="product_brand_name"></el-table-column>
+      <el-table-column label="商品规格" prop="product_spec"></el-table-column>
+      <el-table-column label="单位" prop="product_unit"></el-table-column>
+      <el-table-column label="批发价(元)" prop="product_all_price" min-width="100">
+        <template slot-scope="scope">{{ scope.row.product_all_price | fen2Yuan }}</template>
+      </el-table-column>
+      <el-table-column label="零售价(元)" prop="product_price" min-width="100">
+        <template slot-scope="scope">{{ scope.row.product_price | fen2Yuan }}</template>
+      </el-table-column>
+      <el-table-column label="库存" prop="product_count"></el-table-column>
+      <el-table-column label="类型" prop="product_sale_at">
+        <template slot-scope="scope">{{ scope.row.product_sale_at > 0 ? '现货' : '预售' }}</template>
+      </el-table-column>
+      <el-table-column label="发售时间" prop="product_sale_at" min-width="160">
+        <template slot-scope="scope">{{ scope.row.product_sale_at > 0 ? scope.row.product_sale_at : '' }}</template>
+      </el-table-column>
+      <el-table-column label="农户信息" prop="user_id" show-overflow-tooltip>
+        <template slot-scope="scope">
+          {{ scope.row.user_id }}{{ scope.row.user_name ? '/' + scope.row.user_name : '' }}
+        </template>
+      </el-table-column>
+      <el-table-column label="状态" prop="product_status">
+        <template slot-scope="scope">{{ getProductStatusText(scope.row.product_status) }}</template>
+      </el-table-column>
+      <el-table-column label="推荐标签" prop="product_recommend_lable" min-width="160"
+                       show-overflow-tooltip></el-table-column>
+      <el-table-column label="创建时间" prop="product_check_at" min-width="160"></el-table-column>
+      <el-table-column label="操作" width="120">
+        <template slot-scope="scope">
+          <el-button type="text" @click="del(scope.row)">取消推荐</el-button>
+          <el-button type="text" @click="edit(scope.row)">操作</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <el-pagination
+      class="marginT-20"
+      @size-change="handleSizeChange"
+      @current-change="handleCurrentChange"
+      :hide-on-single-page="true"
+      :current-page="page"
+      :page-size="page_size"
+      :page-sizes="[10, 20, 100, 200, 300, 400]"
+      background
+      layout="total, sizes, prev, pager, next, jumper"
+      :total="totalCount"/>
+    <detail
+      v-if="detailsDialog.show"
+      v-model="detailsDialog.show"
+      :exData="detailsDialog.exData"
+      @success="init"></detail>
+  </div>
 </template>
 
 <script>
+import page from '@/mixin/page'
+import detail from './details'
+
 export default {
-  name: 'index'
+  mixins: [page],
+  components: {
+    detail
+  },
+  data() {
+    return {
+      detailsDialog: {
+        show: false,
+        exData: {}
+      },
+      time: [],
+      searchForm: {},
+      tableData: [],
+      tableUrl: '/api/admin/good/product/list'
+    }
+  },
+  computed: {
+    arrProductSaleType() {
+      return this.$store.state.common.arrProductSaleType
+    },
+    arrProductStatus() {
+      return this.$store.state.common.arrProductStatus
+    }
+  },
+  methods: {
+    edit(row) {
+      this.detailsDialog.exData = row
+      this.detailsDialog.show = true
+    },
+    del(row) {
+      this.$confirm('确定要取消推荐吗', '确认', {
+        type: 'warning'
+      }).then(async () => {
+        const data = await this.$fetch('/api/admin/good/product/recomend', {
+          id: row.id,
+          type: 2 // 类型(1推荐2取消推荐)
+        })
+        if (data.code === 200) {
+          this.$message.success('取消推荐成功')
+          this.init()
+        }
+      }).catch(() => {
+      })
+    },
+    getProductStatusText(val) {
+      const index = this.arrProductStatus.findIndex(item => item.value === val)
+      if (index > -1) {
+        return this.arrProductStatus[index].name
+      }
+      return ''
+    }
+  },
+  mounted() {
+    this.init()
+  }
 }
 </script>
 
-<style scoped>
-
+<style lang="scss" scoped>
 </style>