Prechádzať zdrojové kódy

feat: #暂时对接文档

loki 3 rokov pred
rodič
commit
1ae98f8de1

+ 4 - 8
src/api/photoWarehouse/index.js

@@ -4,15 +4,11 @@ export const getList = params =>
 	api.post(`/yxl-back-end/admin/photo-warehouse/page`, params);
 export const getItem = ({ id, ...params }) =>
 	api.get(`/yxl-back-end/admin/photo-warehouse/${id}`, params);
-export const saveItem = ({ id, ...params }) => {
-	if (id) {
-		// return api.put(`/yxl-back-end/admin/activity/${id}`, params);
-	} else {
-		return api.post(`/yxl-back-end/admin/photo-warehouse/save`, params);
-	}
-};
+export const saveItem = ({ id, ...params }) =>
+	api.post(`/yxl-back-end/admin/photo-warehouse/save`, params);
 export const delItem = ({ id, ...params }) =>
 	api.del(`/yxl-back-end/admin/photo-warehouse/${id}`, params);
 export const auditItem = params =>
 	api.post(`/yxl-back-end/admin/photo-warehouse/audit`, params);
-auditItem;
+export const updateItem = ({ id, ...params }) =>
+	api.put(`/yxl-back-end/admin/photo-warehouse/${id}`, params);

+ 8 - 0
src/utils/dialog-helper.js

@@ -13,6 +13,7 @@ import WithdrawalRecordVerifyItem from 'views/statistics/withdrawalRecord/modal/
 import PhotoerVerifyItem from 'views/photographerManagement/photographerVerify/modal/ItemModal.vue';
 import ActivityItem from 'views/photoManagement/eventsList/modal/ItemModal.vue';
 import PhotoVerifyItem from 'views/photoManagement/photoVerifyManagement/modal/ItemModal.vue';
+import ImageGoodsItem from 'views/photoManagement/imageGoodsManagement/modal/ItemModal.vue';
 
 const modal = (Component, props) => {
   let _component = null;
@@ -125,3 +126,10 @@ let PhotoVerifyItemModal = data => {
 Vue.prototype.$PhotoVerifyItemModal = params => {
   PhotoVerifyItemModal(params);
 };
+
+let ImageGoodsItemModal = data => {
+  modal(ImageGoodsItem, data);
+};
+Vue.prototype.$ImageGoodsItemModal = params => {
+  ImageGoodsItemModal(params);
+};

+ 26 - 1
src/views/photoManagement/imageGoodsManagement/index.vue

@@ -92,7 +92,7 @@ export default {
           width: '80',
           type: 'tag',
           fetchTagType: val => (val ? 'success' : 'info'),
-          tagName: row => (row.isShow ? '显示' : '隐藏')
+          tagName: row => (row.isShow ? '上架' : '下架')
         },
         {
           key: 'action',
@@ -102,6 +102,23 @@ export default {
             const action = [];
             action.push(
               h(
+                'el-button',
+                {
+                  props: {
+                    type: 'text'
+                  },
+                  on: {
+                    click: () =>
+                      this.$ImageGoodsItemModal({
+                        id: row.id
+                      })
+                  }
+                },
+                '编辑'
+              )
+            );
+            action.push(
+              h(
                 'BaseBtn',
                 {
                   props: {
@@ -123,6 +140,14 @@ export default {
         }
       ]
     };
+  },
+
+  created() {
+    this.$g_on('photot_reload', this.reload);
+  },
+
+  beforeDestroy() {
+    this.$g_off('photot_reload', this.reload);
   }
 };
 </script>

+ 165 - 0
src/views/photoManagement/imageGoodsManagement/modal/ItemModal.vue

@@ -0,0 +1,165 @@
+<template>
+  <el-dialog
+    :title="title"
+    :visible.sync="modal"
+    width="500px"
+    :close-on-click-modal="false"
+    @close="
+      res => {
+        $emit('cancel');
+      }
+    "
+  >
+    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+      <el-form-item label="图片"
+        ><img
+          :src="form.listPreview"
+          class="pre-img"
+          @click="
+            () =>
+              this.$AdvanceViewImageModal({
+                items: [{ src: form.listPreview }]
+              })
+          "
+        />
+      </el-form-item>
+
+      <el-form-item label="高清价格图">
+        <el-input-number
+          v-model="form.hdLogoPhotoPrice"
+          :precision="2"
+          :step="0.1"
+          :min="0"
+        ></el-input-number>
+      </el-form-item>
+
+      <el-form-item label="原图价格图">
+        <el-input-number
+          v-model="form.originPhotoPrice"
+          :precision="2"
+          :step="0.1"
+          :min="0"
+        ></el-input-number>
+      </el-form-item>
+
+      <el-form-item label="是否随手拍">
+        <el-radio-group v-model="form.isTake" prop="isShow">
+          <el-radio :label="true">是</el-radio>
+          <el-radio :label="false">否</el-radio>
+        </el-radio-group>
+      </el-form-item>
+
+      <el-form-item label="是否精选">
+        <el-radio-group v-model="form.isBeautiful" prop="isShow">
+          <el-radio :label="true">是</el-radio>
+          <el-radio :label="false">否</el-radio>
+        </el-radio-group>
+      </el-form-item>
+
+      <el-form-item label="状态">
+        <el-radio-group v-model="form.isShow" prop="isShow">
+          <el-radio :label="true">上架</el-radio>
+          <el-radio :label="false">下架</el-radio>
+        </el-radio-group>
+      </el-form-item>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="modal = false">取消</el-button>
+      <el-button type="primary" @click="handleConfirm">确定</el-button>
+    </span>
+  </el-dialog>
+</template>
+
+<script>
+import { getItem, updateItem } from '@/api/photoWarehouse';
+
+export default {
+  name: 'ImageGoodsItemModal',
+
+  props: {
+    id: {
+      type: String,
+      default: ''
+    }
+  },
+
+  data() {
+    return {
+      modal: true,
+
+      form: {
+        isShow: false,
+        isBeautiful: false,
+        isTake: false,
+        originPhotoPrice: 0,
+        hdLogoPhotoPrice: 0
+      },
+      rules: {
+        originPhotoPrice: [
+          { required: true, message: '请输入正确的价格', trigger: 'blur' }
+        ],
+        hdLogoPhotoPrice: [
+          { required: true, message: '请输入正确的价格', trigger: 'blur' }
+        ]
+      },
+
+      typeOptions: []
+    };
+  },
+
+  computed: {
+    title() {
+      if (this.id) {
+        return '编辑照片';
+      } else {
+        return '新增照片';
+      }
+    }
+  },
+
+  watch: {
+    id: {
+      handler(id) {
+        id && this.loadData();
+      },
+      immediate: true
+    }
+  },
+
+  mounted() {},
+
+  methods: {
+    async loadData() {
+      const { success, data, msg } = await getItem({
+        id: this.id
+      });
+      if (success) {
+        let result = data;
+        result.imgUrl = [
+          {
+            url: data.imgUrl
+          }
+        ];
+        this.form = result;
+      }
+    },
+
+    handleConfirm() {
+      this.$refs.form.validate(async valid => {
+        if (valid) {
+          let params = Object.assign({}, this.form);
+          if (this.id) params.id = this.id;
+          const { success, msg } = await updateItem(params);
+          if (success) {
+            this.$success('保存成功!');
+            this.modal = false;
+            this.$g_emit('photot_reload');
+          }
+        }
+      });
+    }
+  }
+};
+</script>
+
+<style lang="scss" scoped></style>