Browse Source

始宁农业管理后台:商品管理

panyong 2 years ago
parent
commit
4cc214fc06

+ 1 - 1
htmldev/shiningManage/src/views/businessManage/toBeReviewed/details.vue

@@ -98,7 +98,7 @@ export default {
           const data = await this.$fetch('/api/admin/shop/check', this.form)
           if (data.code === 200) {
             this.dialog = false
-            this.$message.success('已审核')
+            this.$message('已审核')
             this.$emit('success')
           }
           this.booLock = false

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

@@ -194,6 +194,8 @@
             :disabled="form.product_sale_at === '0'"
             v-model="product_sale_at"
             type="datetime"
+            format="yyyy-MM-dd HH:mm"
+            :picker-options="myPickerOptions"
             placeholder="选择预售日期时间">
           </el-date-picker>
         </el-form-item>
@@ -257,7 +259,16 @@ export default {
     arrProductStatus: {
       type: Array,
       default: function () {
-        return []
+        return [
+          {
+            name: '下架',
+            value: '0'
+          },
+          {
+            name: '上架',
+            value: '1'
+          }
+        ]
       }
     }
   },
@@ -279,7 +290,7 @@ export default {
         'product_all_price': '', // 批发价
         'product_price': '', // 零售价
         'product_count': '', // 库存
-        'product_sale_at': '0', // 发售时间(0代表非预售  时间戳代表预售时间) todo 现售时间
+        'product_sale_at': '0', // 发售时间(0代表非预售  时间戳代表预售时间)
         'product_status': '0' // 商品状态 0下架 1上架
       },
       product_img_url: [],
@@ -298,6 +309,14 @@ export default {
     },
     arrProductUnit() {
       return this.$store.state.common.arrProductUnit
+    },
+    myPickerOptions() {
+      const temp = this.exData.id && this.exData.product_sale_at > 0 ? this.exData.product_sale_at * 1000 : Date.now()
+      return {
+        disabledDate(time) {
+          return time.getTime() < temp - 8.64e7
+        }
+      }
     }
   },
   methods: {
@@ -403,6 +422,7 @@ export default {
                 value = value + ''
               } else {
                 value = '1'
+                this.product_sale_at = new Date(this.exData.product_sale_at * 1000)
               }
             }
             this.$set(this.form, key, value)

+ 40 - 13
htmldev/shiningManage/src/views/productManage/products/index.vue

@@ -50,7 +50,7 @@
       :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_desc" min-width="200"></el-table-column>
       <el-table-column label="商品主图" prop="product_img_url" min-width="100">
         <template slot-scope="scope">
           <el-image
@@ -62,7 +62,7 @@
       </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_spec" min-width="200" show-overflow-tooltip></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>
@@ -75,20 +75,27 @@
         <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>
+        <template slot-scope="scope">
+          <template v-if="scope.row.product_sale_at > 0">
+            {{ scope.row.product_sale_at * 1000 | parseTime('{y}-{m}-{d} {h}:{i}') }}
+          </template>
+          <template v-else>/</template>
+        </template>
       </el-table-column>
-      <el-table-column label="农户信息" prop="user_id" show-overflow-tooltip>
+      <el-table-column label="农户信息" prop="user_id" min-width="160" 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 label="状态" prop="product_status" min-width="100">
+        <template slot-scope="scope">{{ getStatusTextAndColor(scope.row).product_status_text }}</template>
       </el-table-column>
       <el-table-column label="优秀推荐" prop="product_is_recommend" min-width="160">
         <template slot-scope="scope">{{ scope.row.product_is_recommend === 1 ? '是' : '否' }}</template>
       </el-table-column>
-      <el-table-column label="创建时间" prop="product_check_at" min-width="160"></el-table-column>
+      <el-table-column label="审核通过时间" prop="product_check_at" min-width="160"></el-table-column>
+      <el-table-column label="创建时间" prop="created_at" min-width="160"></el-table-column>
+      <el-table-column label="更新时间" prop="updated_at" min-width="160"></el-table-column>
       <el-table-column label="操作" width="120">
         <template slot-scope="scope">
           <el-button type="text" @click="edit(scope.row)">操作</el-button>
@@ -111,7 +118,6 @@
       v-if="detailsDialog.show"
       v-model="detailsDialog.show"
       :exData="detailsDialog.exData"
-      :arrProductStatus="arrProductStatus"
       @success="init"></detail>
   </div>
 </template>
@@ -165,6 +171,7 @@ export default {
       this.detailsDialog.exData = row
       this.detailsDialog.show = true
     },
+    // todo 推荐接口报错
     del(row) {
       this.$confirm('确定要推荐吗', '确认', {
         type: 'warning'
@@ -180,12 +187,32 @@ export default {
       }).catch(() => {
       })
     },
-    getProductStatusText(val) {
-      const index = this.arrProductStatus.findIndex(item => item.value === val + '')
-      if (index > -1) {
-        return this.arrProductStatus[index].name
+    getStatusTextAndColor(row) {
+      // product_check_status 0未审核 1审核成功 2审核失败
+      // product_status 0 未上架 1 上架
+
+      const productStatus = row.product_status
+      const productCheckStatus = row.product_check_status
+      let color = 'col-0'
+      let text = ''
+
+      if (productCheckStatus === 0) {
+        color = 'col-1'
+        text = '审核中'
+      } else if (productCheckStatus === 2) {
+        color = 'col-3'
+        text = '审核未通过'
+      } else if (productCheckStatus === 1 && productStatus === 1) {
+        color = 'col-2'
+        text = '已上架'
+      } else if (productCheckStatus === 1 && productStatus === 0) {
+        text = '未上架'
+      }
+
+      return {
+        product_status_text: text,
+        product_status_color: color
       }
-      return ''
     }
   },
   mounted() {

+ 37 - 10
htmldev/shiningManage/src/views/productManage/recommend/index.vue

@@ -50,7 +50,7 @@
       :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_desc" min-width="200"></el-table-column>
       <el-table-column label="商品主图" prop="product_img_url" min-width="100">
         <template slot-scope="scope">
           <el-image
@@ -75,19 +75,26 @@
         <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>
+        <template slot-scope="scope">
+          <template v-if="scope.row.product_sale_at > 0">
+            {{ scope.row.product_sale_at * 1000 | parseTime('{y}-{m}-{d} {h}:{i}') }}
+          </template>
+          <template v-else>/</template>
+        </template>
       </el-table-column>
-      <el-table-column label="农户信息" prop="user_id" show-overflow-tooltip>
+      <el-table-column label="农户信息" prop="user_id" min-width="160" 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>
+        <template slot-scope="scope">{{ getStatusTextAndColor(scope.row).product_status_text }}</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="审核通过时间" prop="product_check_at" min-width="160"></el-table-column>
+      <el-table-column label="创建时间" prop="created_at" min-width="160"></el-table-column>
+      <el-table-column label="更新时间" prop="updated_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>
@@ -163,12 +170,32 @@ export default {
       }).catch(() => {
       })
     },
-    getProductStatusText(val) {
-      const index = this.arrProductStatus.findIndex(item => item.value === val)
-      if (index > -1) {
-        return this.arrProductStatus[index].name
+    getStatusTextAndColor(row) {
+      // product_check_status 0未审核 1审核成功 2审核失败
+      // product_status 0 未上架 1 上架
+
+      const productStatus = row.product_status
+      const productCheckStatus = row.product_check_status
+      let color = 'col-0'
+      let text = ''
+
+      if (productCheckStatus === 0) {
+        color = 'col-1'
+        text = '审核中'
+      } else if (productCheckStatus === 2) {
+        color = 'col-3'
+        text = '审核未通过'
+      } else if (productCheckStatus === 1 && productStatus === 1) {
+        color = 'col-2'
+        text = '已上架'
+      } else if (productCheckStatus === 1 && productStatus === 0) {
+        text = '未上架'
+      }
+
+      return {
+        product_status_text: text,
+        product_status_color: color
       }
-      return ''
     }
   },
   mounted() {

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

@@ -97,7 +97,7 @@ export default {
           const data = await this.$fetch('/api/admin/product/check', this.form)
           if (data.code === 200) {
             this.dialog = false
-            this.$message.success('已审核')
+            this.$message('已审核')
             this.$emit('success')
           }
           this.booLock = false
@@ -108,6 +108,18 @@ export default {
   mounted() {
     if (this.exData.id) {
       this.$set(this.form, 'id', this.exData.id)
+
+      for (const key in this.exData) {
+        if (key === 'product_check_status' && this.exData[key] > 0) {
+          this.$set(this.form, 'type', this.exData[key] + '')
+        }
+        if (this.form.hasOwnProperty(key)) {
+          let value = this.exData[key]
+          if ((Array.isArray(value) && value.length >= 1) || (Object.prototype.toString.call(value) === '[object Object]') || (typeof value === 'string' && value) || typeof value === 'number') {
+            this.$set(this.form, key, value)
+          }
+        }
+      }
     }
   },
   watch: {

+ 43 - 15
htmldev/shiningManage/src/views/productManage/toBeReviewed/index.vue

@@ -60,7 +60,7 @@
       border
       :max-height="vheight">
       <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_desc" min-width="200"></el-table-column>
       <el-table-column label="商品主图" prop="product_img_url" min-width="100">
         <template slot-scope="scope">
           <el-image
@@ -103,27 +103,35 @@
         <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" 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="product_sale_at">
         <template slot-scope="scope">{{ scope.row.product_sale_at > 0 ? '现货' : '预售' }}</template>
       </el-table-column>
-      <el-table-column label="申请人" prop="user_id" show-overflow-tooltip>
+      <el-table-column label="发售时间" prop="product_sale_at" min-width="160">
+        <template slot-scope="scope">
+          <template v-if="scope.row.product_sale_at > 0">
+            {{ scope.row.product_sale_at * 1000 | parseTime('{y}-{m}-{d} {h}:{i}') }}
+          </template>
+          <template v-else>/</template>
+        </template>
+      </el-table-column>
+      <el-table-column label="申请人" prop="user_id" min-width="160" 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="shop_name" show-overflow-tooltip>
+      <el-table-column label="店铺名称" prop="shop_name" min-width="160" show-overflow-tooltip>
         <template slot-scope="scope">{{ scope.row.shop_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 label="审核状态" prop="product_status" min-width="100">
+        <template slot-scope="scope">{{ getStatusTextAndColor(scope.row).product_status_text }}</template>
       </el-table-column>
       <el-table-column label="申请时间" prop="created_at" min-width="160"></el-table-column>
       <el-table-column label="审核人" prop="product_check_name" min-width="80"></el-table-column>
-      <el-table-column label="审核备注" prop="product_check_remark" min-width="140"
-                       show-overflow-tooltip></el-table-column>
+      <el-table-column
+        label="审核备注"
+        prop="product_check_remark"
+        min-width="140"
+        show-overflow-tooltip></el-table-column>
       <el-table-column label="审核时间" prop="product_check_at" min-width="160"></el-table-column>
       <el-table-column label="操作">
         <template slot-scope="scope">
@@ -184,12 +192,32 @@ export default {
       this.detailsDialog.exData = row
       this.detailsDialog.show = true
     },
-    getProductStatusText(val) {
-      const index = this.arrProductStatus.findIndex(item => item.value === val)
-      if (index > -1) {
-        return this.arrProductStatus[index].name
+    getStatusTextAndColor(row) {
+      // product_check_status 0未审核 1审核成功 2审核失败
+      // product_status 0 未上架 1 上架
+
+      const productStatus = row.product_status
+      const productCheckStatus = row.product_check_status
+      let color = 'col-0'
+      let text = ''
+
+      if (productCheckStatus === 0) {
+        color = 'col-1'
+        text = '审核中'
+      } else if (productCheckStatus === 2) {
+        color = 'col-3'
+        text = '审核未通过'
+      } else if (productCheckStatus === 1 && productStatus === 1) {
+        color = 'col-2'
+        text = '已上架'
+      } else if (productCheckStatus === 1 && productStatus === 0) {
+        text = '未上架'
+      }
+
+      return {
+        product_status_text: text,
+        product_status_color: color
       }
-      return ''
     }
   },
   mounted() {

+ 4 - 1
htmldev/shiningWxMini/pages/businessGoodsEdit/businessGoodsEdit.js

@@ -525,9 +525,11 @@ Page({
       return
     }
     try {
-      let res = await postAddProduct(temp)
+      let res = {}
       if (this.data.form.id) {
         res = await postModifyProduct({ ...temp, id: this.data.form.id })
+      } else {
+        res = await postAddProduct(temp)
       }
       const { status, data, msg } = res
       if (status) {
@@ -543,3 +545,4 @@ Page({
     } catch (err) {}
   }
 })
+// todo 商品编辑:商品分类数据没有回传