逆水行舟 1 тиждень тому
батько
коміт
01634750e0

+ 35 - 19
src/api/maindataMaterialRelevancy.ts

@@ -1,24 +1,40 @@
-import request from '@/benyun/utils/request'
-export function pullItem(data:any){
-	return request({
-		url: '/omsOrder/shopItem/pullItem',
-		method: 'POST',
-		data: data
-	})
+import request from "@/benyun/utils/request";
+export function pullItem(data: any) {
+  return request({
+    url: "/omsOrder/shopItem/pullItem",
+    method: "POST",
+    data: data,
+  });
 }
 
-export function maindataMaterialRelevancy(params:any){
-	return request({
-		url:'/maindata/maindataMaterialRelevancy/page',
-		method:'Get',
-		params:params
-	})
+export function maindataMaterialRelevancy(params: any) {
+  return request({
+    url: "/maindata/maindataMaterialRelevancy/page",
+    method: "Get",
+    params: params,
+  });
 }
 
-export function materialrelevancy(data:any){
-	return request({
-		url:'/maindata/maindataMaterialRelevancy/materialrelevancy',
-		method:'POST',
-		data:data
-	})
+export function materialrelevancy(data: any) {
+  return request({
+    url: "/maindata/maindataMaterialRelevancy/materialrelevancy",
+    method: "POST",
+    data: data,
+  });
+}
+
+export function productStockKeepingUnit(params: any) {
+  return request({
+    url: "/omsOrder/productStockKeepingUnit/list",
+    method: "Get",
+    params: params,
+  });
+}
+
+export function getProductStockKeepingUnit(data: any) {
+  return request({
+    url: "/omsOrder/productStockKeepingUnit/getProductStockKeepingUnit",
+    method: "POST",
+    data: data,
+  });
 }

+ 1 - 1
src/benyun/utils/auth.ts

@@ -6,7 +6,7 @@ const ExpiresInKey = "AdminOMS-Expires-In";
 
 export function getToken() {
   if (process.env.NODE_ENV === "development") {
-    return "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjYyMDZlNDQ3LTJmODktNDdlZS04NmEyLTU2YWNjYTg3MTVlYyIsInVzZXJuYW1lIjoiYWRtaW4ifQ.B3dAuBun-KXKKkE8VF705mkm98uTWKpMmIBB87XHC60qCP_jNTsgU_sCV0hivxsreyqw0fk6kXMrEiEgHJJRLA";
+    return "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6ImY0NzhjODUwLWU5NTAtNGZiZi04MTYxLTE4ZDBiZDliODNmNiIsInVzZXJuYW1lIjoiYWRtaW4ifQ.1l7udZTaQYAgyu-7t7f3rvhpIFVQm9ep2GMvTCacrYB97sEVHZvWDERQxd4VC9xSgATsX2yx7p4sj2t6CUWkQw";
   } else {
     return Cookies.get(TokenKey);
   }

+ 100 - 0
src/views/product/productStockKeepingUnit/components/sync.vue

@@ -0,0 +1,100 @@
+<template>
+    <vxe-modal v-model="value" id="syncOrder" width="500" v-loading="load" @hide="hide" height="300" show-footer
+        title="同步商品(分销商)">
+        <el-form ref="form" :model="form" label-width="100px">
+            <el-form-item label="商品名称" prop="exactlyName">
+                <el-input v-model="form.exactlyName" placeholder="请输入商品名称" clearable></el-input>
+            </el-form-item>
+            <el-form-item label="起始时间" prop="modifiedBegin">
+                <el-date-picker v-model="form.modifiedBegin" type="date" value-format="yyyy-MM-dd"
+                    placeholder="请选择修改时间"></el-date-picker>
+            </el-form-item>
+            <el-form-item label="结束时间" prop="modifiedEnd">
+                <el-date-picker v-model="form.modifiedEnd" type="date" value-format="yyyy-MM-dd"
+                    placeholder="请选择修改时间"></el-date-picker>
+            </el-form-item>
+        </el-form>
+        <template #footer>
+            <div class="btn">
+                <el-button plain size="small" @click="value = false">取消</el-button>
+                <el-button type="primary" size="small" @click="btn">确定</el-button>
+            </div>
+        </template>
+    </vxe-modal>
+</template>
+
+<script lang="ts">
+import { Component, Prop, Vue, Watch } from "vue-property-decorator";
+import { getProductStockKeepingUnit } from '@/api/maindataMaterialRelevancy'
+@Component({ components: {} })
+export default class Sync extends Vue {
+    value = false;
+    load = false;
+    shopList: { channelCompanyId: number, companyName: string }[] = [];
+    form = {
+        exactlyName: '',
+        modifiedBegin: '',
+        modifiedEnd: ''
+    }
+    hide() {
+
+    }
+    setShow(v: boolean) {
+        this.value = v;
+    }
+    setValue(v: any) {
+    }
+    getValue() {
+
+    }
+
+    btn() {
+        if (this.form.exactlyName === '') {
+            this.$message.error('请输入商品名称');
+            return;
+        }
+        if (this.form.modifiedBegin == '') {
+            this.$message.error('请选择起始时间');
+            return;
+        }
+        if (this.form.modifiedEnd == '') {
+            this.$message.error('请选择结束时间');
+            return;
+        }
+        //判断两个时间之间不能大于8天,并且开始时间不能大于结束时间
+        const begin = new Date(this.form.modifiedBegin);
+        const end = new Date(this.form.modifiedEnd);
+        const diff = end.getTime() - begin.getTime();
+        if (diff > 7 * 24 * 60 * 60 * 1000) {
+            this.$message.error('时间范围不能大于7天');
+            return;
+        }
+        if (begin.getTime() > end.getTime()) {
+            this.$message.error('开始时间不能大于结束时间');
+            return;
+        }
+        this.$confirm('确认同步商品吗?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+        }).then(() => {
+            let formData = (this as any).$lodash.cloneDeep(this.form);
+            getProductStockKeepingUnit(formData).then(res => {
+                this.$message.success('同步成功');
+            }).catch((err) => {
+                console.error(err);
+            }).finally(() => {
+                this.load = false;
+                this.form = {
+                    exactlyName: '',
+                    modifiedBegin: '',
+                    modifiedEnd: ''
+                }
+            })
+        })
+    }
+
+}
+</script>
+
+<style lang="scss" scoped></style>

+ 207 - 0
src/views/product/productStockKeepingUnit/index.vue

@@ -0,0 +1,207 @@
+<template>
+    <div class="m-box" v-loading="load">
+        <moduleView :propConfig="config" ref="view" @search="search" @pagination="pagination" @resert="resert" />
+        <sync ref="sync" />
+    </div>
+</template>
+
+<script lang="ts">
+import { Component, Prop, Vue, Watch } from "vue-property-decorator";
+import Sync from "./components/sync.vue";
+import { productStockKeepingUnit, materialrelevancy } from '@/api/maindataMaterialRelevancy'
+@Component({ components: { Sync } })
+export default class SynchronousProduct extends Vue {
+    load = false;
+    currentRow: any = null;
+    count = 0;
+    time: any = null;
+    config: any = {
+        attr: {
+            calculateH: true
+        },
+        search: {
+            attr: {
+                size: 'mini',
+                rules: {
+                    name: [{
+                        required: true, message: '请输入名称', trigger: 'blur'
+                    }]
+                }
+            },
+            columns: [
+                [{
+                    span: 6,
+                    label: '商品名称',
+                    prop: 'name',
+                    component: 'by-input',
+                    compConfig: {
+                    }
+                }]
+            ]
+        },
+        tool: {
+            customTools: [
+                {
+                    name: '商品同步', icon: 'el-icon-setting', event: {
+                        click: () => {
+                            (this.$refs.sync as any).setShow(true);
+                        }
+                    }
+                }
+            ]
+        },
+        table: {
+            attr: {
+                size: 'mini',
+                align: 'center'
+            },
+            columns: [{
+                title: '商品编码',
+                field: 'skuId',
+                width: 150
+            }, {
+                title: '商品名称',
+                field: 'name'
+            }, {
+                title: '商品简称',
+                field: 'shortName'
+            }, {
+                title: '品牌',
+                field: 'brand'
+            }, {
+                title: '单位',
+                field: 'unit'
+            }, {
+                title: '商品标签',
+                field: 'labels'
+            }, {
+                title: '销售价',
+                field: 'salePrice',
+                width: 140
+            },
+                // {
+                //     title: '操作',
+                //     action: true,
+                //     width: 170,
+                //     plugins: [{
+                //         name: '关联商品',
+                //         audit: '',
+                //         event: {
+                //             show: (row: any) => {
+                //                 return row.isSync != 1
+                //             },
+                //             click: (item: any) => {
+                //                 (this.$refs.sku as any).setShow(true);
+                //                 this.setCurrentRow(item);
+                //             }
+                //         }
+                //     }
+                //     ]
+                // }
+            ]
+        }
+    }
+
+    mounted() {
+        this.$nextTick(() => {
+            this.time = setInterval(() => {
+                this.getSyncData()
+            }, 500)
+
+        })
+    }
+    setCurrentRow(row: any) {
+        this.currentRow = row;
+    }
+    //商品同步成功
+    handleSuccess() {
+        let data = (this.$refs.view as any).getPage();
+        data.pageNo = 1;
+        this.getList(data);
+    }
+    pagination(page: any) {
+        let data: any = (this.$refs.view as any).getQuery();
+        this.getList(data);
+    }
+    resert() {
+        let data = (this.$refs.view as any).getPage();
+        data.pageNo = 1;
+        this.getList(data);
+    }
+    search() {
+        let data: any = (this.$refs.view as any).getQuery();
+        data.pageNo = 1;
+        this.getList(data);
+    }
+    getList(data: any) {
+        let page: any = {
+            pageNo: data.pageNo,
+            pageSize: data.pageSize
+        }
+
+        this.load = true;
+
+        data.pageNum = data.pageNo;
+        delete data.pageNo;
+        delete data.total;
+
+        productStockKeepingUnit(data).then((res: any) => {
+            this.load = false;
+            if (this.$refs.view) {
+                (this.$refs.view as any).setTableValue(res.rows);
+                page.pageNo = res.pageNum;
+                page.total = res.total;
+                (this.$refs.view as any).setPage(page);
+            }
+        }).catch((err: any) => {
+            this.load = false;
+        })
+    }
+    //列表数据
+    getSyncData() {
+        this.count++;
+        if (this.count >= 5) {
+            clearInterval(this.time)
+            return
+        }
+        if (!this.$refs.view) {
+            return
+        }
+        this.count = 0;
+        clearInterval(this.time)
+        let data = (this.$refs.view as any).getPage();
+
+        this.getList(data);
+    }
+
+    confirmProduct(data: Array<any>) {
+        if (data.length == 0) {
+            this.$message('请选择商品!');
+            return;
+        }
+        let value: any = {
+            lid: this.currentRow.id,
+            mskuid: data[0].id
+        }
+        this.load = true;
+        materialrelevancy(value).then((res: any) => {
+            this.load = false;
+            this.$message({
+                message: '商品关联成功!',
+                type: 'success'
+            })
+            this.getSyncData();
+        }).catch((err: any) => {
+            this.load = false;
+            this.$message.error('商品关联失败!')
+        })
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+.m-box {
+    height: 100%;
+    width: 100%;
+}
+</style>