Commit 14dc8140 by liangjianmin

Merge branch 'feature/ljm/20250710-优化'

parents 4db1300c beecb027
......@@ -48,7 +48,7 @@
<el-dropdown-item command="1">修改安全库存</el-dropdown-item>
<el-dropdown-item command="2">修改交期</el-dropdown-item>
<el-dropdown-item command="3">上架有效期</el-dropdown-item>
<el-dropdown-item command="4">修改销售价格</el-dropdown-item>
<el-dropdown-item command="4">修改成本价格</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
......@@ -94,8 +94,8 @@
<el-table-column prop="stock" label="可用库存数量" width="100" align="center" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="in_transit_stock" label="在途库存" width="100" align="center" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="consignment_safe_stock" label="安全库存" width="100" align="center" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="cn_ladder_price" label="含税销售价(¥)" width="120" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope" v-if="scope.row.cn_ladder_price && scope.row.cn_ladder_price.length>0">
<el-table-column prop="cn_ladder_price" label="含税成本价(¥)" width="120" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope" v-if="scope.row.cn_ladder_price && scope.row.cn_ladder_price.length > 0">
<el-popover effect="light" trigger="hover" placement="bottom">
<p class="row" v-for="item in scope.row.cn_ladder_price">
<span>{{ item.purchases }}+</span>
......@@ -105,8 +105,8 @@
</el-popover>
</template>
</el-table-column>
<el-table-column prop="hk_ladder_price" label="美金销售价($)" width="120" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope" v-if="scope.row.cn_ladder_price && scope.row.cn_ladder_price.length>0">
<el-table-column prop="hk_ladder_price" label="美金成本价($)" width="120" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope" v-if="scope.row.cn_ladder_price && scope.row.cn_ladder_price.length > 0">
<el-popover effect="light" trigger="hover" placement="bottom">
<p class="row" v-for="item in scope.row.hk_ladder_price">
<span>{{ item.purchases }}+</span>
......@@ -162,8 +162,8 @@
<el-table-column prop="source_val" label="来源" width="150" align="center" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="goods_status" label="状态" width="100" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.goods_status==1" class="f-green">上架</span>
<span v-else-if="scope.row.goods_status==3">下架</span>
<span v-if="scope.row.goods_status == 1" class="f-green">上架</span>
<span v-else-if="scope.row.goods_status == 3">下架</span>
</template>
</el-table-column>
<el-table-column prop="cp_time" label="上架有效期" width="150" align="center" :show-overflow-tooltip="true"></el-table-column>
......@@ -192,9 +192,9 @@
</el-table>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="submitKc">确 定</el-button>
</span>
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="submitKc">确 定</el-button>
</span>
</el-dialog>
<!--修改交期弹窗-->
<el-dialog title="修改交期" :close-on-click-modal="false" :visible.sync="dialogVisible2" width="900px">
......@@ -221,9 +221,9 @@
</el-table>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible2 = false">取 消</el-button>
<el-button type="primary" @click="submitHq">确 定</el-button>
</span>
<el-button @click="dialogVisible2 = false">取 消</el-button>
<el-button type="primary" @click="submitHq">确 定</el-button>
</span>
</el-dialog>
<!--修改上架有效期弹窗-->
<el-dialog title="修改上架有效期" :close-on-click-modal="false" :visible.sync="dialogVisible3" width="900px">
......@@ -233,8 +233,8 @@
<el-table-column prop="brand_name" label="品牌" min-width="20%" :show-overflow-tooltip="true"></el-table-column>
<el-table-column prop="goods_status" label="状态" width="80" :show-overflow-tooltip="true">
<template slot-scope="scope">
<span v-if="scope.row.goods_status==1" class="f-green">上架</span>
<span v-else-if="scope.row.goods_status==3">下架</span>
<span v-if="scope.row.goods_status == 1" class="f-green">上架</span>
<span v-else-if="scope.row.goods_status == 3">下架</span>
</template>
</el-table-column>
<el-table-column prop="cp_time_temp" label="上架有效期" width="160" :show-overflow-tooltip="true"></el-table-column>
......@@ -246,12 +246,12 @@
</el-table>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible3 = false">取 消</el-button>
<el-button type="primary" @click="submitCp">确 定</el-button>
</span>
<el-button @click="dialogVisible3 = false">取 消</el-button>
<el-button type="primary" @click="submitCp">确 定</el-button>
</span>
</el-dialog>
<!--修改销售价格-->
<el-dialog title="修改销售价格" :close-on-click-modal="false" :visible.sync="dialogVisible4" width="900px">
<!--修改成本价格-->
<el-dialog title="修改成本价格" :close-on-click-modal="false" :visible.sync="dialogVisible4" width="900px">
<div class="kc-mask">
<el-table :data="priceData" border max-height="600" style="margin-bottom: 10px">
<el-table-column label="商品信息" width="100%">
......@@ -269,12 +269,12 @@
<el-input v-model="skuOriginalStepPriceData[scope.$index].purchases" @input="handleInput(scope.$index)" placeholder="起订量" onkeyup="if(event.keyCode !=37 &amp;&amp; event.keyCode != 39){if (!/^[\d]+$/ig.test(this.value)){this.value='';}}"></el-input>
</template>
</el-table-column>
<el-table-column prop="price_cn" label="含税销售价(RMB)" min-width="20%" :show-overflow-tooltip="true">
<el-table-column prop="price_cn" label="含税成本价(RMB)" min-width="20%" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-input v-model="skuOriginalStepPriceData[scope.$index].price_cn" placeholder="¥"></el-input>
</template>
</el-table-column>
<el-table-column prop="price_us" label="美金销售价(USD)" min-width="20%" :show-overflow-tooltip="true">
<el-table-column prop="price_us" label="美金成本价(USD)" min-width="20%" :show-overflow-tooltip="true">
<template slot-scope="scope">
<el-input v-model="skuOriginalStepPriceData[scope.$index].price_us" placeholder="$"></el-input>
</template>
......@@ -291,9 +291,9 @@
<i class="el-icon-plus add" @click="addRow" style="color: #409EFF;cursor: pointer;margin-top: 20px;">增加阶梯价</i>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible4 = false">取 消</el-button>
<el-button type="primary" @click="updateSkuOriginalStepPrice">确 定</el-button>
</span>
<el-button @click="dialogVisible4 = false">取 消</el-button>
<el-button type="primary" @click="updateSkuOriginalStepPrice">确 定</el-button>
</span>
</el-dialog>
<!--弹窗日志-->
<el-dialog title="现货库存管理日志" :close-on-click-modal="false" :visible.sync="dialogVisibleLog" width="1000px">
......@@ -301,7 +301,7 @@
<el-table-column prop="create_time" label="时间" min-width="150" align="center"></el-table-column>
<el-table-column prop="message" label="操作说明" min-width="150" align="center">
<template slot-scope="scope">
<span>修改了价格,点击查看 <a style="color: #409EFF" href="javascript:;" @click="handleDetailClick(scope.row.message.pre_data,scope.row.message.current_data)">修改详情</a></span>
<span>修改了价格,点击查看 <a style="color: #409EFF" href="javascript:;" @click="handleDetailClick(scope.row.message.pre_data, scope.row.message.current_data)">修改详情</a></span>
</template>
</el-table-column>
<el-table-column prop="operator" label="操作人" min-width="150" align="center"></el-table-column>
......@@ -338,13 +338,13 @@
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">
<el-link type="primary" href="/批量修改.csv" :underline="false">下载模板</el-link>
<el-link type="primary" :href="jsHref" :underline="false">下载模板</el-link>
</div>
</el-upload>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisibleBatchModify = false">取 消</el-button>
<el-button type="primary" @click="">确 定</el-button>
</span>
<el-button @click="dialogVisibleBatchModify = false">取 消</el-button>
<el-button type="primary" @click="">确 定</el-button>
</span>
</el-dialog>
<!--寄售召回-->
<el-dialog title="寄售召回" :close-on-click-modal="false" :visible.sync="dialogVisibleConsignmentRecall" width="900px">
......@@ -362,471 +362,370 @@
</el-table>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisibleConsignmentRecall = false">取 消</el-button>
<el-button type="primary" @click="addConsignmentRecallFromStock">确 定</el-button>
</span>
<el-button @click="dialogVisibleConsignmentRecall = false">取 消</el-button>
<el-button type="primary" @click="addConsignmentRecallFromStock">确 定</el-button>
</span>
</el-dialog>
<Menu/>
<Menu />
</div>
</template>
<script>
import Vue from 'vue';
import Menu from "@/components/menu.vue";
import {Autocomplete, Button, DatePicker, Dialog, Dropdown, DropdownItem, DropdownMenu, Form, FormItem, Input, Link, Message, Option, Pagination, Popover, Select, Table, TableColumn, Tag, Tooltip, Upload} from 'element-ui'
import Util from "@/tool";
import {NODE_ENVS} from "@/ajax";
import Vue from 'vue';
import Menu from "@/components/menu.vue";
import { Autocomplete, Button, DatePicker, Dialog, Dropdown, DropdownItem, DropdownMenu, Form, FormItem, Input, Link, Message, Option, Pagination, Popover, Select, Table, TableColumn, Tag, Tooltip, Upload } from 'element-ui'
import Util from "@/tool";
import { NODE_ENVS } from "@/ajax";
Vue.prototype.$message = Message
Vue.use(Button).use(Form).use(Select).use(Option).use(Input).use(FormItem).use(Dialog).use(Tooltip).use(Autocomplete).use(Tag).use(Link)
Vue.use(DatePicker).use(Upload).use(Dropdown).use(DropdownMenu).use(DropdownItem).use(TableColumn).use(Table).use(Pagination).use(Popover)
export default {
name: "consignmentInventory",
data() {
return {
total: 0,
limit: 10,
page: 1,
dialogVisible: false,//库存弹窗
dialogVisible2: false,//交期弹窗
dialogVisible3: false,//上架有效期
dialogVisible4: false,//修改价格
dialogVisibleLog: false,//日志
dialogVisibleLogDetail: false,//日志详情
dialogVisibleBatchModify: false,//批量修改
dialogVisibleConsignmentRecall: false,//寄售召回
consignmentRecallData: [],//寄售召回数据
logs: [],
downHref: "",
cp_time_val: '',
formParam: {
goods_name: '',
status: '',
brand_name: '',
date: '',
cp_time: '',
source: ''
},
multipleSelection: [],
selectData: [],
huoqidata: [],//修改交期数据
kucundata: [],//修改库存数据
cpdata: [],//上架有效期数据
priceData: [],//修改价格数据
message: {},
skuOriginalStepPriceData: [],
goods_id: '',
stock: 0,
tableData: [],
brandList: [],
disabled: false,
timer: null,
skuStatistics: {},//统计数据
skuRankList: {},//sku的型号统计排名列表
pickerOptions: {
disabledDate: this.disabledDate
},
uploadUrl: NODE_ENVS + '/api/sku/batchUpdateSku',
uploadHeaders: {
'Authorization': 'Bearer ' + Util.getCookie('token')
}
};
},
created() {
this.getData();
this.getSkuRankList();
},
methods: {
/**
* 查看日志
* @param row
*/
handleClick(row) {
this.getLogs(507, row.goods_id);
},
/**
* 查看日志详情
* @param row
*/
handleDetailClick(pre_data, current_data) {
var data = Object.assign({}, {
pre_data: pre_data,
current_data: current_data
});
this.dialogVisibleLogDetail = true;
this.message = data;
},
/**
* 获取日志
* @param obj_type
* @param obj_id
*/
getLogs(obj_type, obj_id) {
this.$http('GET', "/api/log/getLogs", {
obj_type: obj_type,
obj_id: obj_id
}).then(res => {
if (res.code === 0) {
this.dialogVisibleLog = true;
this.logs = res.data.list;
} else {
this.$message({
message: res.msg,
type: 'warning'
});
Vue.prototype.$message = Message
Vue.use(Button).use(Form).use(Select).use(Option).use(Input).use(FormItem).use(Dialog).use(Tooltip).use(Autocomplete).use(Tag).use(Link)
Vue.use(DatePicker).use(Upload).use(Dropdown).use(DropdownMenu).use(DropdownItem).use(TableColumn).use(Table).use(Pagination).use(Popover)
export default {
name: "consignmentInventory",
data() {
return {
jsHref: location.hostname === 'xinlian.ichunt.com' ? 'https://cloud.ichunt.com/template/批量修改寄售商品模板.csv' : 'http://cloud.liexindev.net/template/批量修改寄售商品模板.csv',
total: 0,
limit: 10,
page: 1,
dialogVisible: false,//库存弹窗
dialogVisible2: false,//交期弹窗
dialogVisible3: false,//上架有效期
dialogVisible4: false,//修改价格
dialogVisibleLog: false,//日志
dialogVisibleLogDetail: false,//日志详情
dialogVisibleBatchModify: false,//批量修改
dialogVisibleConsignmentRecall: false,//寄售召回
consignmentRecallData: [],//寄售召回数据
logs: [],
downHref: "",
cp_time_val: '',
formParam: {
goods_name: '',
status: '',
brand_name: '',
date: '',
cp_time: '',
source: ''
},
multipleSelection: [],
selectData: [],
huoqidata: [],//修改交期数据
kucundata: [],//修改库存数据
cpdata: [],//上架有效期数据
priceData: [],//修改价格数据
message: {},
skuOriginalStepPriceData: [],
goods_id: '',
stock: 0,
tableData: [],
brandList: [],
disabled: false,
timer: null,
skuStatistics: {},//统计数据
skuRankList: {},//sku的型号统计排名列表
pickerOptions: {
disabledDate: this.disabledDate
},
uploadUrl: NODE_ENVS + '/api/sku/batchUpdateSku',
uploadHeaders: {
'Authorization': 'Bearer ' + Util.getCookie('token')
}
});
},
/**
* 关闭弹窗
*/
closeBothDialogs() {
this.dialogVisibleLog = false;
this.dialogVisibleLogDetail = false;
},
/**
* 修改价格删除
* @param index
* @param row
*/
handleDelete(index, row) {
this.skuOriginalStepPriceData.splice(index, 1);
};
},
/**
* 监听起订量
*/
handleInput(index) {
var val = Number(this.skuOriginalStepPriceData[index].purchases) || 0;
var max = Number(this.stock) || 0;
if (val > max) {
this.$set(this.skuOriginalStepPriceData[index], 'purchases', max);
}
created() {
this.getData();
this.getSkuRankList();
},
/**
* 获取数据
*/
getData() {
//格式化时间
if (this.cp_time_val) {
this.formParam.cp_time = this.cp_time_val[0] + '~' + this.cp_time_val[1];
} else {
this.formParam.cp_time = '';
}
var params = Object.assign({}, this.formParam, { page: this.page, limit: this.limit, source: 12 }, { action_time: this.formParam.date ? this.formParam.date[0] : '' }, { end_time: this.formParam.date ? this.formParam.date[1] : '' })
this.$http('GET', "/api/sku/list", params).then(res => {
if (res.code === 0) {
this.tableData = res.data.list || [];
this.total = Number(res.data.count) || 0;
} else {
this.$message({
message: res.msg,
type: 'warning'
});
methods: {
/**
* 查看日志
* @param row
*/
handleClick(row) {
this.getLogs(507, row.goods_id);
},
/**
* 查看日志详情
* @param row
*/
handleDetailClick(pre_data, current_data) {
var data = Object.assign({}, {
pre_data: pre_data,
current_data: current_data
});
this.dialogVisibleLogDetail = true;
this.message = data;
},
/**
* 获取日志
* @param obj_type
* @param obj_id
*/
getLogs(obj_type, obj_id) {
this.$http('GET', "/api/log/getLogs", {
obj_type: obj_type,
obj_id: obj_id
}).then(res => {
if (res.code === 0) {
this.dialogVisibleLog = true;
this.logs = res.data.list;
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
});
},
/**
* 关闭弹窗
*/
closeBothDialogs() {
this.dialogVisibleLog = false;
this.dialogVisibleLogDetail = false;
},
/**
* 修改价格删除
* @param index
* @param row
*/
handleDelete(index, row) {
this.skuOriginalStepPriceData.splice(index, 1);
},
/**
* 监听起订量
*/
handleInput(index) {
var val = Number(this.skuOriginalStepPriceData[index].purchases) || 0;
var max = Number(this.stock) || 0;
if (val > max) {
this.$set(this.skuOriginalStepPriceData[index], 'purchases', max);
}
})
},
/**
* 获取sku的型号统计排名列表
*/
getSkuRankList() {
this.$http('GET', "/api/sku/getSkuRankList", {}).then(res => {
if (res.code === 0) {
this.skuRankList = res.data.rankList;
},
/**
* 获取数据
*/
getData() {
//格式化时间
if (this.cp_time_val) {
this.formParam.cp_time = this.cp_time_val[0] + '~' + this.cp_time_val[1];
} else {
this.$message({
message: res.msg,
type: 'warning'
});
this.formParam.cp_time = '';
}
})
},
/**
* 型号
* @param queryString
* @param cb
*/
querySearchAsync(queryString, cb) {
if (!queryString) {
cb([]);
return;
}
this.$http('GET', "/api/search/getspu", { spu_name: queryString }).then(res => {
if (res.code == 0 && res.data.list?.length) {
const arr = res.data.list.map(item => ({
value: item.spu_name
}));
cb(arr);
} else {
var params = Object.assign({}, this.formParam, { page: this.page, limit: this.limit, source: 12 }, { action_time: this.formParam.date ? this.formParam.date[0] : '' }, { end_time: this.formParam.date ? this.formParam.date[1] : '' })
this.$http('GET', "/api/sku/list", params).then(res => {
if (res.code === 0) {
this.tableData = res.data.list || [];
this.total = Number(res.data.count) || 0;
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
})
},
/**
* 获取sku的型号统计排名列表
*/
getSkuRankList() {
this.$http('GET', "/api/sku/getSkuRankList", {}).then(res => {
if (res.code === 0) {
this.skuRankList = res.data.rankList;
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
})
},
/**
* 型号
* @param queryString
* @param cb
*/
querySearchAsync(queryString, cb) {
if (!queryString) {
cb([]);
return;
}
}).catch(() => {
cb([]);
});
},
/**
* 品牌
* @param queryString
* @param cb
*/
querySearchAsyncBrand(queryString, cb) {
this.$http('get', "/api/brand/get_stand_brand", {
brand: queryString
}).then(res => {
if (res.code == 0) {
if (res.data.list.length > 0) {
var arrlist_ = res.data.list || [];
var arr_ = []
for (var i = 0; i < arrlist_.length; i++) {
arr_.push({
value: arrlist_[i]
})
}
cb(arr_);
this.$http('GET', "/api/search/getspu", { spu_name: queryString }).then(res => {
if (res.code == 0 && res.data.list?.length) {
const arr = res.data.list.map(item => ({
value: item.spu_name
}));
cb(arr);
} else {
cb([]);
}
}
})
},
downOut() {
if (this.disabled) {
this.$message({
message: '正在导出中,请不要重复点击',
type: 'warning'
}).catch(() => {
cb([]);
});
return
}
this.$http('get', "/api/sku/exportSku", {
page: this.page,
limit: this.limit,
goods_name: this.formParam.goods_name,
status: this.formParam.status,
brand_id: this.formParam.brand_id,
brand_name: this.formParam.brand_name,
action_time: this.formParam.date[0],
end_time: this.formParam.date[1],
source: 12
}).then(res => {
if (res.code == 0) {
this.disabled = true
this.$message({
message: '正在导出中,请耐心等待',
type: 'success'
});
this.timer = setInterval(() => {
if (!this.disabled) {
clearInterval(this.timer)
return
},
/**
* 品牌
* @param queryString
* @param cb
*/
querySearchAsyncBrand(queryString, cb) {
this.$http('get', "/api/brand/get_stand_brand", {
brand: queryString
}).then(res => {
if (res.code == 0) {
if (res.data.list.length > 0) {
var arrlist_ = res.data.list || [];
var arr_ = []
for (var i = 0; i < arrlist_.length; i++) {
arr_.push({
value: arrlist_[i]
})
}
cb(arr_);
} else {
cb([]);
}
this.resultDown(res.data)
}, 3000)
}
})
},
resultDown(id_) {
this.$http('get', "/api/export/get_export_data", {
id: id_
}).then(res => {
if (res.code == 0) {
this.disabled = false;
this.$message({
message: '导出成功',
type: 'success'
});
this.downHref = res.data;
const newsUrl = this.$router.resolve(res.data);
window.open(res.data);
} else if (res.code == -1) {
//导出失败
}
})
},
downOut() {
if (this.disabled) {
this.$message({
message: '导出失败',
message: '正在导出中,请不要重复点击',
type: 'warning'
});
this.disabled = false;
return
}
}, error => {
this.$message('网络出现问题,请检查网络');
this.disabled = false
})
},
resetForm(formName) {
this.formParam.date = '';
this.cp_time_val = '';
this.$refs[formName].resetFields();
this.formParam.status = '';
},
onSubmit() {
this.page = 1;
this.getData();
},
handleSizeChange(val) {
this.limit = val;
this.getData();
},
handleCurrentChange(val) {
this.page = val;
this.getData();
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
disabledDate(date) {
var maxDate = new Date(); // 设置最大日期
var minDate = new Date(); // 设置最小日期
var cp_time_day = localStorage.getItem('cp_time_day');
if (cp_time_day == -1) {
// “无限制”,则修改上架有效期默认为:2035-01-01
var maxDate = new Date('2035-01-01');
} else {
var maxDate = new Date(new Date().getTime() + cp_time_day * 24 * 60 * 60 * 1000);
}
this.$http('get', "/api/sku/exportSku", {
page: this.page,
limit: this.limit,
goods_name: this.formParam.goods_name,
status: this.formParam.status,
brand_id: this.formParam.brand_id,
brand_name: this.formParam.brand_name,
action_time: this.formParam.date[0],
end_time: this.formParam.date[1],
source: 12
}).then(res => {
if (res.code == 0) {
this.disabled = true
this.$message({
message: '正在导出中,请耐心等待',
type: 'success'
});
this.timer = setInterval(() => {
if (!this.disabled) {
clearInterval(this.timer)
return
}
this.resultDown(res.data)
}, 3000)
}
})
},
resultDown(id_) {
this.$http('get', "/api/export/get_export_data", {
id: id_
}).then(res => {
if (res.code == 0) {
this.disabled = false;
this.$message({
message: '导出成功',
type: 'success'
});
this.downHref = res.data;
const newsUrl = this.$router.resolve(res.data);
window.open(res.data);
} else if (res.code == -1) {
//导出失败
this.$message({
message: '导出失败',
type: 'warning'
});
this.disabled = false;
}
}, error => {
this.$message('网络出现问题,请检查网络');
this.disabled = false
})
},
resetForm(formName) {
this.formParam.date = '';
this.cp_time_val = '';
this.$refs[formName].resetFields();
this.formParam.status = '';
},
onSubmit() {
this.page = 1;
this.getData();
},
handleSizeChange(val) {
this.limit = val;
this.getData();
},
handleCurrentChange(val) {
this.page = val;
this.getData();
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
disabledDate(date) {
var maxDate = new Date(); // 设置最大日期
var minDate = new Date(); // 设置最小日期
return date > maxDate || date < minDate; // 返回 true 禁用日期,返回 false 启用日期
},
/**
*
* @param date 时间类型
* @param type 是否加30天
* @returns {string}
*/
getTimes(date, type) {
if (type) {
var cp_time_day = localStorage.getItem('cp_time_day');
if (cp_time_day == -1) {
// “无限制”,则修改上架有效期默认为:2035-01-01
var date = new Date('2035-01-01');
var maxDate = new Date('2035-01-01');
} else {
var date = new Date(new Date().getTime() + cp_time_day * 24 * 60 * 60 * 1000);
var maxDate = new Date(new Date().getTime() + cp_time_day * 24 * 60 * 60 * 1000);
}
} else {
var date = new Date(date);
}
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
month >= 1 && month <= 9 ? (month = '0' + month) : '';
day >= 0 && day <= 9 ? (day = '0' + day) : '';
var timer = year + '-' + month + '-' + day + ' ' + 0 + ':' + 0 + ':' + 0;
return timer;
},
/**
* 统计查看
* @param val
*/
showChange(row) {
this.$http('GET', "/api/sku/getSkuStatistics", {
goods_name: row.goods_name,
brand_name: row.brand_name
}).then(res => {
if (res.code == 0) {
this.skuStatistics = res.data.statisticsData;
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
})
},
/**
* 修改按钮
* @param command
*/
handleCommand(command) {
if (this.multipleSelection.length == 0) {
this.$message({
message: '请至少选择一条数据',
type: 'warning'
});
return;
}
// 修改价格时检查是否只选择了一条数据
if (command == 4 && this.multipleSelection.length > 1) {
this.$message({
message: '只能选择一条数据',
type: 'warning'
});
return;
}
this.selectData = JSON.parse(JSON.stringify(this.multipleSelection));
if (command == 1) {
//修改库存弹窗
this.dialogVisible = true;
this.kucundata = this.selectData;
} else if (command == 2) {
//修改货期弹窗
this.dialogVisible2 = true;
this.huoqidata = this.selectData;
} else if (command == 3) {
//修改上架有效期
this.dialogVisible3 = true;
let currentTime = new Date().getTime();//当前日期毫秒
for (let i = 0; i < this.selectData.length; i++) {
this.selectData[i].cp_time_temp = this.selectData[i].cp_time;
var time = Date.parse(this.selectData[i].cp_time);//上架有效期
if (time > currentTime) {
//上架有效期大于当前日期
this.selectData[i].cp_time = this.getTimes(this.selectData[i].cp_time, true);
return date > maxDate || date < minDate; // 返回 true 禁用日期,返回 false 启用日期
},
/**
*
* @param date 时间类型
* @param type 是否加30天
* @returns {string}
*/
getTimes(date, type) {
if (type) {
var cp_time_day = localStorage.getItem('cp_time_day');
if (cp_time_day == -1) {
// “无限制”,则修改上架有效期默认为:2035-01-01
var date = new Date('2035-01-01');
} else {
//上架有效期小于等于当前日期
this.selectData[i].cp_time = this.getTimes(new Date(), true);
var date = new Date(new Date().getTime() + cp_time_day * 24 * 60 * 60 * 1000);
}
} else {
var date = new Date(date);
}
this.cpdata = this.selectData;
} else if (command == 4) {
//修改价格
this.dialogVisible4 = true;
this.priceData = this.selectData;
this.getSkuOriginalStepPrice(this.selectData[0].goods_id);
this.stock = this.selectData[0].stock;
}
},
/**
* 增加阶梯价
*/
addRow() {
if (this.skuOriginalStepPriceData.length >= 9) {
this.$message({
message: '已超过阶梯限制',
type: 'warning'
});
return false;
}
this.skuOriginalStepPriceData.push({
cost_price: '',
price_cn: '',
price_us: '',
purchases: ''
})
},
/**
* 修改阶梯价格
*/
updateSkuOriginalStepPrice() {
var isPurchasesValid = Util.isPurchasesValid(this.skuOriginalStepPriceData);
if (!isPurchasesValid) {
this.$message({
message: '修改价格时格式填写错误,起订量不能低于最小起订量,不能高于库存;并且需要填写对应价格;',
type: 'warning'
});
} else {
this.$http('GET', "/api/sku/updateSkuOriginalStepPrice", { goods_id: this.goods_id, original_price: JSON.stringify(this.skuOriginalStepPriceData) }).then(res => {
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
var minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
var second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
month >= 1 && month <= 9 ? (month = '0' + month) : '';
day >= 0 && day <= 9 ? (day = '0' + day) : '';
var timer = year + '-' + month + '-' + day + ' ' + 0 + ':' + 0 + ':' + 0;
return timer;
},
/**
* 统计查看
* @param val
*/
showChange(row) {
this.$http('GET', "/api/sku/getSkuStatistics", {
goods_name: row.goods_name,
brand_name: row.brand_name
}).then(res => {
if (res.code == 0) {
this.$message({
message: '操作成功',
type: 'success'
});
setTimeout(() => {
this.dialogVisible4 = false;
this.getData();
}, 2000)
this.skuStatistics = res.data.statisticsData;
} else {
this.$message({
message: res.msg,
......@@ -834,86 +733,188 @@ export default {
});
}
})
}
},
/**
* 获取sku阶梯价格
*/
getSkuOriginalStepPrice(goods_id) {
this.$http('GET', "/api/sku/getSkuOriginalStepPrice", { goods_id: goods_id }).then(res => {
if (res.code == 0) {
this.skuOriginalStepPriceData = res.data.data;
this.goods_id = goods_id;
} else {
},
/**
* 修改按钮
* @param command
*/
handleCommand(command) {
if (this.multipleSelection.length == 0) {
this.$message({
message: res.msg,
message: '请至少选择一条数据',
type: 'warning'
});
return;
}
})
},
/**
* 修改上架有效期
*/
submitCp() {
var arr_ = {}
for (var i = 0; i < this.cpdata.length; i++) {
arr_[this.cpdata[i]['goods_id']] = {}
if (this.cpdata[i]['cp_time'] && this.cpdata[i]['cp_time'] != 'undefined') {
arr_[this.cpdata[i]['goods_id']].cp_time = this.cpdata[i]['cp_time']
}
}
this.$http('post', "/api/sku/updateSku", arr_).then(res => {
if (res.code == 0) {
// 修改价格时检查是否只选择了一条数据
if (command == 4 && this.multipleSelection.length > 1) {
this.$message({
message: '修改成功',
type: 'success'
message: '只能选择一条数据',
type: 'warning'
});
this.getData();
this.dialogVisible3 = false;
} else {
return;
}
this.selectData = JSON.parse(JSON.stringify(this.multipleSelection));
if (command == 1) {
//修改库存弹窗
this.dialogVisible = true;
this.kucundata = this.selectData;
} else if (command == 2) {
//修改货期弹窗
this.dialogVisible2 = true;
this.huoqidata = this.selectData;
} else if (command == 3) {
//修改上架有效期
this.dialogVisible3 = true;
let currentTime = new Date().getTime();//当前日期毫秒
for (let i = 0; i < this.selectData.length; i++) {
this.selectData[i].cp_time_temp = this.selectData[i].cp_time;
var time = Date.parse(this.selectData[i].cp_time);//上架有效期
if (time > currentTime) {
//上架有效期大于当前日期
this.selectData[i].cp_time = this.getTimes(this.selectData[i].cp_time, true);
} else {
//上架有效期小于等于当前日期
this.selectData[i].cp_time = this.getTimes(new Date(), true);
}
}
this.cpdata = this.selectData;
} else if (command == 4) {
//修改价格
this.dialogVisible4 = true;
this.priceData = this.selectData;
this.getSkuOriginalStepPrice(this.selectData[0].goods_id);
this.stock = this.selectData[0].stock;
}
},
/**
* 增加阶梯价
*/
addRow() {
if (this.skuOriginalStepPriceData.length >= 9) {
this.$message({
message: res.msg,
message: '已超过阶梯限制',
type: 'warning'
});
return false;
}
})
},
/**
* 修改交期提交
*/
submitHq() {
var arr_ = {}
for (var i = 0; i < this.huoqidata.length; i++) {
arr_[this.huoqidata[i]['goods_id']] = {}
if (this.huoqidata[i]['dlhq'] && this.huoqidata[i]['dlhq'] != 'undefined') {
arr_[this.huoqidata[i]['goods_id']].cn_delivery_time = this.huoqidata[i]['dlhq']
this.skuOriginalStepPriceData.push({
cost_price: '',
price_cn: '',
price_us: '',
purchases: ''
})
},
/**
* 修改阶梯价格
*/
updateSkuOriginalStepPrice() {
var isPurchasesValid = Util.isPurchasesValid(this.skuOriginalStepPriceData);
if (!isPurchasesValid) {
this.$message({
message: '修改价格时格式填写错误,起订量不能低于最小起订量,不能高于库存;并且需要填写对应价格;',
type: 'warning'
});
} else {
this.$http('GET', "/api/sku/updateSkuOriginalStepPrice", { goods_id: this.goods_id, original_price: JSON.stringify(this.skuOriginalStepPriceData) }).then(res => {
if (res.code == 0) {
this.$message({
message: '操作成功',
type: 'success'
});
setTimeout(() => {
this.dialogVisible4 = false;
this.getData();
}, 2000)
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
})
}
if (this.huoqidata[i]['hkhq'] && this.huoqidata[i]['hkhq'] != 'undefined') {
arr_[this.huoqidata[i]['goods_id']].hk_delivery_time = this.huoqidata[i]['hkhq']
},
/**
* 获取sku阶梯价格
*/
getSkuOriginalStepPrice(goods_id) {
this.$http('GET', "/api/sku/getSkuOriginalStepPrice", { goods_id: goods_id }).then(res => {
if (res.code == 0) {
this.skuOriginalStepPriceData = res.data.data;
this.goods_id = goods_id;
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
})
},
/**
* 修改上架有效期
*/
submitCp() {
var arr_ = {}
for (var i = 0; i < this.cpdata.length; i++) {
arr_[this.cpdata[i]['goods_id']] = {}
if (this.cpdata[i]['cp_time'] && this.cpdata[i]['cp_time'] != 'undefined') {
arr_[this.cpdata[i]['goods_id']].cp_time = this.cpdata[i]['cp_time']
}
}
}
this.$http('post', "/api/sku/updateSku", arr_).then(res => {
if (res.code == 0) {
this.$message("修改成功");
this.getData()
this.dialogVisible2 = false
} else {
this.$message(res.msg);
this.$http('post', "/api/sku/updateSku", arr_).then(res => {
if (res.code == 0) {
this.$message({
message: '修改成功',
type: 'success'
});
this.getData();
this.dialogVisible3 = false;
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
})
},
/**
* 修改交期提交
*/
submitHq() {
var arr_ = {}
for (var i = 0; i < this.huoqidata.length; i++) {
arr_[this.huoqidata[i]['goods_id']] = {}
if (this.huoqidata[i]['dlhq'] && this.huoqidata[i]['dlhq'] != 'undefined') {
arr_[this.huoqidata[i]['goods_id']].cn_delivery_time = this.huoqidata[i]['dlhq']
}
if (this.huoqidata[i]['hkhq'] && this.huoqidata[i]['hkhq'] != 'undefined') {
arr_[this.huoqidata[i]['goods_id']].hk_delivery_time = this.huoqidata[i]['hkhq']
}
}
})
},
/**
* 修改库存提交
*/
submitKc() {
// 使用reduce将库存数据转换为对象
const stockUpdates = this.kucundata.reduce((acc, item) => ({
...acc,
[item.goods_id]: { stock: item.updateStock }
}), {});
this.$http('post', "/api/sku/updateSku", arr_).then(res => {
if (res.code == 0) {
this.$message("修改成功");
this.getData()
this.dialogVisible2 = false
} else {
this.$message(res.msg);
}
})
},
/**
* 修改库存提交
*/
submitKc() {
// 使用reduce将库存数据转换为对象
const stockUpdates = this.kucundata.reduce((acc, item) => ({
...acc,
[item.goods_id]: { stock: item.updateStock }
}), {});
this.$http('post', "/api/sku/updateSku", stockUpdates)
this.$http('post', "/api/sku/updateSku", stockUpdates)
.then(res => {
if (res.code === 0) {
this.$message({
......@@ -929,200 +930,200 @@ export default {
});
}
});
},
/**
* 上下架
* @param status
*/
changeStatus(status) {
var time_arr = [];//过滤出上架有效期时间数组
var sku_ids = [];//过滤出sku_ids数组
if (this.multipleSelection.length == 0) {
this.$message({
message: '请至少选择一条数据',
type: 'warning'
});
return;
}
if (status == 1) {
var time = new Date();//当前时间
time_arr = this.multipleSelection.map(obj => {
return obj.cp_time;
});
var times = time_arr.filter((item) => {
if (new Date(item) < time) {
return item;
}
});
if (times.length > 0) {
},
/**
* 上下架
* @param status
*/
changeStatus(status) {
var time_arr = [];//过滤出上架有效期时间数组
var sku_ids = [];//过滤出sku_ids数组
if (this.multipleSelection.length == 0) {
this.$message({
message: '您勾选的数据中,有型号的“上架有效期”低于当前的日期,请先维护上架有效期;',
message: '请至少选择一条数据',
type: 'warning'
});
return;
}
}
sku_ids = this.multipleSelection.map(obj => {
return obj.goods_id;
});
this.$http('post', "/api/sku/updateSkuStatus", { sku_ids: sku_ids.join(","), status: status == 1 ? 'passed' : 'offshelf' }).then(res => {
if (res.code === 0) {
this.$message({
message: '操作成功',
type: 'success'
if (status == 1) {
var time = new Date();//当前时间
time_arr = this.multipleSelection.map(obj => {
return obj.cp_time;
});
this.getData()
} else {
this.$message({
message: res.msg,
type: 'warning'
var times = time_arr.filter((item) => {
if (new Date(item) < time) {
return item;
}
});
}
})
},
/**
* 弹窗事件
*/
popupEvent(type) {
switch (type) {
case 1:
this.dialogVisibleBatchModify = true;
break;
case 2:
if (!this.multipleSelection.length) {
this.$message.warning('请选择数据');
if (times.length > 0) {
this.$message({
message: '您勾选的数据中,有型号的“上架有效期”低于当前的日期,请先维护上架有效期;',
type: 'warning'
});
return;
}
var html = `
}
sku_ids = this.multipleSelection.map(obj => {
return obj.goods_id;
});
this.$http('post', "/api/sku/updateSkuStatus", { sku_ids: sku_ids.join(","), status: status == 1 ? 'passed' : 'offshelf' }).then(res => {
if (res.code === 0) {
this.$message({
message: '操作成功',
type: 'success'
});
this.getData()
} else {
this.$message({
message: res.msg,
type: 'warning'
});
}
})
},
/**
* 弹窗事件
*/
popupEvent(type) {
switch (type) {
case 1:
this.dialogVisibleBatchModify = true;
break;
case 2:
if (!this.multipleSelection.length) {
this.$message.warning('请选择数据');
return;
}
var html = `
<p style="font-size: 14px;">确定将选择的商品提交寄售申请?</p>
<p style="font-size: 14px;color: #FF7E11">确认后请到【寄售申请】菜单编辑申请寄售数量,并提交审核</p>
`
this.$confirm(html, '寄售申请', {
confirmButtonText: '确定',
cancelButtonText: '取消',
dangerouslyUseHTMLString: true
}).then(() => {
let sku_ids = this.multipleSelection.map(item => item.goods_id).join(',');
this.$http('POST', "/api/consignmentReplenishment/addConsignmentReplenishment", { sku_ids: sku_ids }).then(res => {
if (res.code === 0) {
this.$message({
message: res.msg,
type: 'success',
onClose: () => {
this.getData();
}
});
} else {
this.$message.error(res.msg || '操作失败');
}
})
}).catch(() => {
// 取消时不需要提示
});
break;
case 3:
if (!this.multipleSelection.length) {
this.$message.warning('请选择数据');
return;
}
this.consignmentRecallData = this.multipleSelection.map(item => {
return {
sku_id: item.goods_id,
goods_name: item.goods_name,
brand_name: item.brand_name,
stock: item.stock,
date_code: item.batch_sn,//批次
recall_num: item.stock
this.$confirm(html, '寄售申请', {
confirmButtonText: '确定',
cancelButtonText: '取消',
dangerouslyUseHTMLString: true
}).then(() => {
let sku_ids = this.multipleSelection.map(item => item.goods_id).join(',');
this.$http('POST', "/api/consignmentReplenishment/addConsignmentReplenishment", { sku_ids: sku_ids }).then(res => {
if (res.code === 0) {
this.$message({
message: res.msg,
type: 'success',
onClose: () => {
this.getData();
}
});
} else {
this.$message.error(res.msg || '操作失败');
}
})
}).catch(() => {
// 取消时不需要提示
});
break;
case 3:
if (!this.multipleSelection.length) {
this.$message.warning('请选择数据');
return;
}
});
this.dialogVisibleConsignmentRecall = true;
break;
}
},
/**
* 上传成功
* @param res
* @param file
* @param fileList
*/
handleUploadSuccess(res, file, fileList) {
if (res.code === 0) {
this.$message({
message: res.msg,
type: 'success',
onClose: () => {
this.dialogVisibleBatchModify = false;
}
});
} else {
this.$message.error(res.msg || '上传失败');
}
},
/**
* 上传失败
* @param err
* @param file
* @param fileList
*/
handleUploadError(err, file, fileList) {
this.$message.error('上传失败,请重试');
},
/**
* 输入验证
* @param row
*/
validateInput(row) {
// 转换为数字进行比较
let inputValue = Number(row.recall_num) || 0;
let stockValue = Number(row.stock) || 0;
// 如果输入值大于库存,则设置为库存值
if (inputValue > stockValue) {
row.recall_num = stockValue;
this.$message({
message: '申请召回数量不能大于可用库存数量',
type: 'warning'
});
}
},
/**
* 寄售库存-新增寄售召回单
*/
addConsignmentRecallFromStock() {
// 检查是否有空的召回数量
const hasEmptyRecallNum = this.consignmentRecallData.some(item => !item.recall_num);
if (hasEmptyRecallNum) {
this.$message({
message: '请填写申请召回数量',
type: 'warning'
});
return;
}
this.$http('POST', "/api/consignmentRecall/addConsignmentRecallFromStock", {
recall_json: JSON.stringify(this.consignmentRecallData)
}).then(res => {
this.consignmentRecallData = this.multipleSelection.map(item => {
return {
sku_id: item.goods_id,
goods_name: item.goods_name,
brand_name: item.brand_name,
stock: item.stock,
date_code: item.batch_sn,//批次
recall_num: item.stock
}
});
this.dialogVisibleConsignmentRecall = true;
break;
}
},
/**
* 上传成功
* @param res
* @param file
* @param fileList
*/
handleUploadSuccess(res, file, fileList) {
if (res.code === 0) {
this.$message({
message: '操作成功',
message: res.msg,
type: 'success',
onClose: () => {
this.dialogVisibleConsignmentRecall = false;
this.getData();
this.dialogVisibleBatchModify = false;
}
});
} else {
this.$message.error(res.msg || '操作失败');
this.$message.error(res.msg || '上传失败');
}
},
/**
* 上传失败
* @param err
* @param file
* @param fileList
*/
handleUploadError(err, file, fileList) {
this.$message.error('上传失败,请重试');
},
/**
* 输入验证
* @param row
*/
validateInput(row) {
// 转换为数字进行比较
let inputValue = Number(row.recall_num) || 0;
let stockValue = Number(row.stock) || 0;
// 如果输入值大于库存,则设置为库存值
if (inputValue > stockValue) {
row.recall_num = stockValue;
this.$message({
message: '申请召回数量不能大于可用库存数量',
type: 'warning'
});
}
},
/**
* 寄售库存-新增寄售召回单
*/
addConsignmentRecallFromStock() {
// 检查是否有空的召回数量
const hasEmptyRecallNum = this.consignmentRecallData.some(item => !item.recall_num);
if (hasEmptyRecallNum) {
this.$message({
message: '请填写申请召回数量',
type: 'warning'
});
return;
}
})
this.$http('POST', "/api/consignmentRecall/addConsignmentRecallFromStock", {
recall_json: JSON.stringify(this.consignmentRecallData)
}).then(res => {
if (res.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
onClose: () => {
this.dialogVisibleConsignmentRecall = false;
this.getData();
}
});
} else {
this.$message.error(res.msg || '操作失败');
}
})
}
},
components: {
Menu
}
},
components: {
Menu
}
};
};
</script>
<style scoped>
@import "../../assets/css/store/list.min.css";
@import "../../assets/css/store/list.min.css";
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment