耗材列表盘点
This commit is contained in:
parent
ce546e09b2
commit
44e15448d9
|
|
@ -13,7 +13,8 @@
|
|||
<el-radio-button label="custom">自定义</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-date-picker v-model="query.createdAt" type="daterange" range-separator="至" start-placeholder="开始日期"
|
||||
end-placeholder="结束日期" :clearable="false" :default-time="['00:00:00', '23:59:59']" value-format="yyyyMMdd">
|
||||
end-placeholder="结束日期" :clearable="false" :default-time="['00:00:00', '23:59:59']"
|
||||
value-format="yyyyMMdd">
|
||||
</el-date-picker>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getTableData">查询</el-button>
|
||||
|
|
@ -49,9 +50,10 @@
|
|||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="">
|
||||
<el-table-column label="" width='120px'>
|
||||
<template v-slot="scope">
|
||||
<el-button type="primary" @click="clicksee(scope.row)">查看</el-button>
|
||||
<el-button type="text" @click="clicksee(scope.row)">查看</el-button>
|
||||
<el-button type="text" @click="clickexport(scope.row)">导出</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
@ -62,9 +64,9 @@
|
|||
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
||||
</div>
|
||||
<el-dialog title="商品销量" :visible.sync="dialogshow">
|
||||
<el-table :data="tableDatainfo.data" style="width: 100%">
|
||||
<el-table-column prop="productName" label="商品名称"/>
|
||||
<el-table-column prop="num" label="数量"/>
|
||||
<el-table :data="tableDatainfo.data" style="width: 100%;height: 500px;overflow: auto;">
|
||||
<el-table-column prop="productName" label="商品名称" />
|
||||
<el-table-column prop="num" label="数量" />
|
||||
<el-table-column prop="amount" label="金额" />
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
|
|
@ -73,6 +75,7 @@
|
|||
|
||||
<script>
|
||||
import { tbHandoverGet } from '@/api/homes/record.js'
|
||||
import XLSX from 'xlsx';
|
||||
import dayjs from "dayjs";
|
||||
export default {
|
||||
data() {
|
||||
|
|
@ -239,8 +242,23 @@ export default {
|
|||
// 查看
|
||||
clicksee(e) {
|
||||
this.dialogshow = true
|
||||
console.log(JSON.parse(e.productInfos))
|
||||
// console.log(JSON.parse(e.productInfos))
|
||||
this.tableDatainfo.data = JSON.parse(e.productInfos)
|
||||
},
|
||||
|
||||
clickexport(e) {
|
||||
const arr = JSON.parse(e.productInfos)
|
||||
let data = [
|
||||
['商品名称', '数量', '金额'],
|
||||
]
|
||||
arr.forEach(element => {
|
||||
data.push([element.productName, element.num, element.amount])
|
||||
});
|
||||
|
||||
const ws = XLSX.utils.aoa_to_sheet(data);
|
||||
const wb = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
|
||||
XLSX.writeFile(wb, 'data.xlsx');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,33 +1,36 @@
|
|||
<!-- 新增耗材盘点 -->
|
||||
<!-- 耗材列表的新增耗材盘点 -->
|
||||
<template>
|
||||
<el-dialog title="耗材盘点" :visible.sync="dialogVisible" width="80%" @open="form.note = ''">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-position="left" inline>
|
||||
<el-form-item label="账存数量">
|
||||
<el-input :value="detail.num" readonly style="width: 180px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="实际数量">
|
||||
<el-input-number v-model="form.lpNum" :min="0" :step="1" step-strictly style="width: 180px;"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="盈亏数量">
|
||||
<el-input :value="profitNumber" readonly :class="{ lose: profitNumber < 0 }" style="width: 180px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="单价">
|
||||
<el-input v-model="detail.price" readonly></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="盈亏金额">
|
||||
<el-input :value="profitPrice" readonly :class="{ lose: profitNumber < 0 }" style="width: 180px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" style="width: 180px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="dialogVisible = false; form.remark = ''">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="onSubmitHandle">确 定</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="head-container">
|
||||
<el-table ref="table" :data="tableData.list" v-loading="tableData.loading" border stripe>
|
||||
<!-- <el-table-column label="商品信息" width="150px">
|
||||
<el-dialog title="耗材盘点" :visible.sync="dialogVisible" width="80%" @open="form.note = ''">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-position="left" inline>
|
||||
<el-form-item label="账存数量">
|
||||
<el-input v-model="form.balance" readonly style="width: 180px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="实际数量">
|
||||
<el-input-number v-model="form.stocktakinNum" :min="0" :step="1" step-strictly
|
||||
style="width: 180px;"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="盈亏数量">
|
||||
<el-input v-model="profitNumber" readonly :class="{ lose: profitNumber < 0 }"
|
||||
style="width: 180px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="单价">
|
||||
<el-input v-model="form.price" readonly></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="盈亏金额">
|
||||
<el-input v-model="profitPrice" readonly :class="{ lose: profitNumber < 0 }"
|
||||
style="width: 180px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="form.remark" placeholder="请输入备注" style="width: 300px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="onSubmitHandle">确 定</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="head-container">
|
||||
<el-table ref="table" :data="tableData.list" v-loading="tableData.loading" border stripe>
|
||||
<el-table-column label="商品信息" width="150px">
|
||||
<template v-slot="scope">
|
||||
<div class="shop_info">
|
||||
<el-image :src="scope.row.coverImg" style="width: 30px;height: 30px;">
|
||||
|
|
@ -35,183 +38,165 @@
|
|||
<i class="icon el-icon-document-delete"></i>
|
||||
</div>
|
||||
</el-image>
|
||||
<span>{{ scope.row.name }}</span>
|
||||
<span>{{ scope.row.conName }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column label="售价" prop="price">
|
||||
<template v-slot="scope">
|
||||
¥{{ formatDecimal(scope.row.price) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="帐存库存" prop="stockNumber"></el-table-column>
|
||||
<el-table-column label="盈亏数量" prop="lpNum"></el-table-column>
|
||||
<el-table-column label="盈亏金额" prop="lpAmount">
|
||||
<template v-slot="scope">
|
||||
¥{{ formatDecimal(scope.row.lpAmount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="实际库存" prop="acStockNumber"></el-table-column>
|
||||
<el-table-column label="备注" prop="remark"></el-table-column>
|
||||
<el-table-column label="盘点时间" prop="createTime"></el-table-column>
|
||||
<!-- <el-table-column label="盘点备注" prop="note"></el-table-column> -->
|
||||
</el-table>
|
||||
</div>
|
||||
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-sizes="[5, 10, 30, 50]"
|
||||
:page-size="tableData.size" @current-change="paginationChange" @size-change="sizeChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
||||
</el-dialog>
|
||||
</el-table-column>
|
||||
<el-table-column label="售价" prop="price">
|
||||
<template v-slot="scope">
|
||||
¥{{ scope.row.price }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="账存数量" prop="stockNumber"></el-table-column>
|
||||
<el-table-column label="盈亏数量" prop="lpNum"></el-table-column>
|
||||
<el-table-column label="盈亏金额" prop="lpAmount">
|
||||
<template v-slot="scope">
|
||||
¥{{ scope.row.lpAmount }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="实际库存" prop="acStockNumber"></el-table-column>
|
||||
<el-table-column label="盘点时间" prop="createTime"></el-table-column>
|
||||
<el-table-column label="盘点备注" prop="remark"></el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-sizes="[5, 10, 30, 50]"
|
||||
:page-size="tableData.size" @current-change="paginationChange" @size-change="sizeChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"></el-pagination>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { formatDecimal } from "@/utils";
|
||||
import { tbConCheck, tbConCheckGet } from "@/api/invoicing";
|
||||
import { formatDecimal } from '@/utils'
|
||||
import { tbConCheck, tbConCheckGet } from '@/api/invoicing'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
formatDecimal,
|
||||
dialogVisible: false,
|
||||
loading: false,
|
||||
detail: "",
|
||||
form: {
|
||||
conInfoId: "",
|
||||
lpNum: 0
|
||||
},
|
||||
rules: {
|
||||
stocktakinNum: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入盘点数量",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
},
|
||||
resetForm: "",
|
||||
searhForm: {
|
||||
name: "",
|
||||
skuId: "",
|
||||
productId: ""
|
||||
},
|
||||
tableData: {
|
||||
page: 0,
|
||||
size: 5,
|
||||
total: 0,
|
||||
loading: false,
|
||||
list: []
|
||||
}
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.resetForm = { ...this.form };
|
||||
},
|
||||
computed: {
|
||||
profitNumber() {
|
||||
return formatDecimal(this.form.lpNum - this.detail.num, 2, true);
|
||||
},
|
||||
profitPrice() {
|
||||
return formatDecimal(
|
||||
(this.form.lpNum - this.detail.num) * this.detail.price
|
||||
);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSubmitHandle() {
|
||||
this.$refs.form.validate(async valid => {
|
||||
if (valid) {
|
||||
try {
|
||||
this.loading = true;
|
||||
let res = await tbConCheck({
|
||||
conInfoId: this.form.conInfoId,
|
||||
lpNum: this.profitNumber,
|
||||
remark: this.form.remark,
|
||||
stockNumber: this.form.lpNum
|
||||
});
|
||||
this.detail.num = this.form.lpNum;
|
||||
this.form.lpNum = 0;
|
||||
this.form.lpNum = this.detail.num;
|
||||
|
||||
this.$emit("success", res);
|
||||
this.loading = false;
|
||||
this.$message({
|
||||
title: "注意",
|
||||
message: `添加成功`,
|
||||
type: "success"
|
||||
});
|
||||
this.form.remark = ''
|
||||
this.getTableData();
|
||||
} catch (error) {
|
||||
this.loading = false;
|
||||
console.log(error);
|
||||
}
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
loading: false,
|
||||
form: {
|
||||
skuId: '', // sku商品必传
|
||||
productId: '', // 必传
|
||||
stocktakinNum: '', // 必传
|
||||
price: '', // 商品价格 非必传 为空盘点价格为商品价格
|
||||
note: "" // 盘点备注 非必传
|
||||
},
|
||||
rules: {
|
||||
stocktakinNum: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入盘点数量',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
},
|
||||
resetForm: '',
|
||||
searhForm: {
|
||||
name: '',
|
||||
skuId: '',
|
||||
productId: ''
|
||||
},
|
||||
tableData: {
|
||||
page: 0,
|
||||
size: 5,
|
||||
total: 0,
|
||||
loading: false,
|
||||
list: []
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
show(obj) {
|
||||
// console.log(obj);
|
||||
this.detail = { ...obj };
|
||||
this.detail.num = formatDecimal(
|
||||
obj.stockNumber - obj.stockConsume,
|
||||
2,
|
||||
false
|
||||
);
|
||||
this.dialogVisible = true;
|
||||
this.form.conInfoId = obj.id;
|
||||
this.form.lpNum = this.detail.num;
|
||||
mounted() {
|
||||
this.resetForm = { ...this.form }
|
||||
},
|
||||
computed: {
|
||||
profitNumber() {
|
||||
return this.form.stocktakinNum - this.form.balance
|
||||
},
|
||||
profitPrice() {
|
||||
return formatDecimal(this.profitNumber * this.form.price && 0)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSubmitHandle() {
|
||||
this.$refs.form.validate(async valid => {
|
||||
if (valid) {
|
||||
try {
|
||||
this.form.lpNum = this.profitNumber
|
||||
this.loading = true
|
||||
let res = await tbConCheck(this.form)
|
||||
this.$emit('success', res)
|
||||
// this.dialogVisible = false
|
||||
this.loading = false
|
||||
this.$notify({
|
||||
title: '注意',
|
||||
message: `添加成功`,
|
||||
type: 'success'
|
||||
});
|
||||
this.getTableData()
|
||||
} catch (error) {
|
||||
this.loading = false
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
show(obj) {
|
||||
this.form = Object.assign(this.form, obj)
|
||||
this.dialogVisible = true
|
||||
this.form.conInfoId = obj.consId
|
||||
this.form.stockNumber = obj.balance
|
||||
|
||||
this.searhForm.skuId = obj.productId;
|
||||
this.searhForm.productId = obj.proId;
|
||||
|
||||
this.tableData.page = 0;
|
||||
this.tableData.total = 0;
|
||||
this.tableData.list = [];
|
||||
this.getTableData();
|
||||
},
|
||||
// 分页大小改变
|
||||
sizeChange(e) {
|
||||
this.tableData.size = e;
|
||||
this.getTableData();
|
||||
},
|
||||
// 分页回调
|
||||
paginationChange(e) {
|
||||
this.tableData.page = e - 1;
|
||||
this.getTableData();
|
||||
},
|
||||
// 商品列表
|
||||
async getTableData() {
|
||||
try {
|
||||
this.tableData.loading = true;
|
||||
const res = await tbConCheckGet({
|
||||
page: this.tableData.page,
|
||||
size: this.tableData.size,
|
||||
conInfoId: this.form.conInfoId,
|
||||
sort: "id,desc"
|
||||
});
|
||||
this.tableData.list = res.content;
|
||||
this.tableData.total = res.totalElements;
|
||||
setTimeout(() => {
|
||||
this.tableData.loading = false;
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
this.searhForm.skuId = obj.productId
|
||||
this.searhForm.productId = obj.consId
|
||||
this.getTableData()
|
||||
},
|
||||
// 分页大小改变
|
||||
sizeChange(e) {
|
||||
this.tableData.size = e
|
||||
this.getTableData()
|
||||
},
|
||||
// 分页回调
|
||||
paginationChange(e) {
|
||||
this.tableData.page = e - 1
|
||||
this.getTableData()
|
||||
},
|
||||
// 商品列表
|
||||
async getTableData() {
|
||||
try {
|
||||
this.tableData.loading = true
|
||||
const res = await tbConCheckGet({
|
||||
page: this.tableData.page,
|
||||
size: this.tableData.size,
|
||||
name: this.searhForm.name,
|
||||
skuId: this.searhForm.category,
|
||||
productId: this.searhForm.productId,
|
||||
sort: 'id,desc',
|
||||
})
|
||||
this.tableData.list = res.content
|
||||
this.tableData.total = res.totalElements
|
||||
setTimeout(() => {
|
||||
this.tableData.loading = false
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.lose {
|
||||
&::v-deep .el-input__inner {
|
||||
color: rgb(238, 29, 29);
|
||||
}
|
||||
&::v-deep .el-input__inner {
|
||||
color: rgb(238, 29, 29);
|
||||
}
|
||||
}
|
||||
|
||||
.shop_info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
span {
|
||||
margin-left: 10px;
|
||||
}
|
||||
span {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -29,6 +29,11 @@
|
|||
<el-option :label="item.label" :value="item.value" v-for="item in typeEnums" :key="item.label" />
|
||||
</el-select>
|
||||
</div>
|
||||
<div style="width: 300px;">
|
||||
<el-select clearable v-model="query.sort" placeholder="排序">
|
||||
<el-option label="按数量排序" value="balance,desc" />
|
||||
</el-select>
|
||||
</div>
|
||||
<el-button type="primary" @click="getTableData">查询</el-button>
|
||||
<el-button @click="resetHandle">重置</el-button>
|
||||
</div>
|
||||
|
|
@ -48,17 +53,13 @@
|
|||
<div class="head-container" id="table_drag">
|
||||
<el-table ref="table" :data="tableData.data" v-loading="tableData.loading" row-key="id">
|
||||
<!-- <el-table-column prop="id" label="ID" width="50px" /> -->
|
||||
<el-table-column label="耗材名称" prop="conName" />
|
||||
<el-table-column label="耗材代码" prop="conCode" />
|
||||
<el-table-column label="分类名称" prop="conTypeName" />
|
||||
<el-table-column label="单位" prop="conUnit" />
|
||||
<el-table-column label="创建时间" prop="createTime" width="200">
|
||||
<template v-slot="scope">
|
||||
{{ dayjs(scope.row.createTime).format("YYYY-MM-DD HH:mm:ss") }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="耗材名称" prop="conName" align="center" />
|
||||
<!-- <el-table-column label="耗材代码" prop="conCode" /> -->
|
||||
<el-table-column label="分类名称" prop="conTypeName" align="center" />
|
||||
<el-table-column label="单位" prop="conUnit" align="center" />
|
||||
|
||||
<el-table-column label="现有库存">
|
||||
|
||||
<el-table-column label="现有库存" align="center">
|
||||
<template v-slot="scope">
|
||||
<span :class="[computedClass(scope.row.balance)]"> {{ scope.row.balance }}</span>
|
||||
</template>
|
||||
|
|
@ -80,30 +81,41 @@
|
|||
<!-- <el-table-column label="正负号标识" prop="bizType" /> -->
|
||||
<!-- <el-table-column label="耗材id" prop="consId" /> -->
|
||||
<!-- <el-table-column label="创建时间" prop="createTime"></el-table-column> -->
|
||||
<el-table-column label="所属商品" width="320" align="center">
|
||||
<!-- <el-table-column label="所属商品" width="320" align="center">
|
||||
<template v-slot="scope">
|
||||
<!-- <el-button v-for="(item) in scope.row.product" @click="toGoods(item)" :key="item.productId" type="text">{{
|
||||
item.productName }}</el-button> -->
|
||||
<el-button v-for="(item) in scope.row.product" @click="toGoods(item)" :key="item.productId" type="text">{{
|
||||
item.productName }}</el-button>
|
||||
{{ scope.row.productId }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
<el-table-column label="所属商品" width="320" align="center">
|
||||
<template v-slot="scope">
|
||||
<el-button v-for="(item) in scope.row.product" @click="toGoods(item)" :key="item.productId" type="text">{{
|
||||
item.productName }}</el-button>
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="最近入库量" prop="lasterInStock" /> -->
|
||||
<el-table-column label="库存数量" prop="stockNumber">
|
||||
<el-table-column label="库存数量" align="center" prop="stockNumber">
|
||||
<template v-slot="scope">
|
||||
{{ (scope.row.balance).toFixed(2) }}
|
||||
<!-- {{ (scope.row.stockNumber - scope.row.stockConsume).toFixed(2) }} -->
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="预警值" prop="conWarning" />
|
||||
<el-table-column label="预警值" align="center" prop="conWarning" />
|
||||
<!-- <el-table-column label="单位耗材值" prop="surplusStock" /> -->
|
||||
<!-- <el-table-column label="排序" prop="sort" sortable /> -->
|
||||
<el-table-column label="更新时间" prop="updateTime" width="200">
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
|
||||
<!-- <template v-slot="scope">
|
||||
{{ dayjs(scope.row.createdAt).format('YYYY-MM-DD HH:mm:ss') }}
|
||||
{{ dayjs(scope.row.createTime).format("YYYY-MM-DD HH:mm:ss") }}
|
||||
</template> -->
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="更新时间" prop="updateTime" width="200"> -->
|
||||
<!-- <template v-slot="scope">
|
||||
{{ dayjs(scope.row.createdAt).format('YYYY-MM-DD HH:mm:ss') }}
|
||||
</template> -->
|
||||
<!-- </el-table-column> -->
|
||||
<el-table-column label="操作" width="250" fixed="right">
|
||||
<template v-slot="scope">
|
||||
<el-button type="text" @click="editorHandle(scope.row)">编辑</el-button>
|
||||
|
|
@ -528,6 +540,15 @@ export default {
|
|||
this.$message({ type: "error", message: "至少保留一种耗材" });
|
||||
}
|
||||
},
|
||||
toGoods(data) {
|
||||
|
||||
this.$router.push({
|
||||
path: '/product/product',
|
||||
query: {
|
||||
productId: data.productId
|
||||
}
|
||||
})
|
||||
},
|
||||
//添加耗材弹窗增加
|
||||
ruleFormsAdd() {
|
||||
console.log('add')
|
||||
|
|
@ -612,9 +633,24 @@ export default {
|
|||
shopId: localStorage.getItem("shopId")
|
||||
});
|
||||
this.tableData.loading = false;
|
||||
this.tableData.data = res.content;
|
||||
// this.tableData.data = res.content;
|
||||
this.tableData.total = res.totalElements;
|
||||
|
||||
this.tableData.data = res.content.map(v => {
|
||||
const productIds = v.productId ? v.productId.split(',') : []
|
||||
return {
|
||||
...v,
|
||||
product: productIds.map((str, index) => {
|
||||
const startIndex = str.indexOf('_')
|
||||
const productId = str.slice(0, startIndex)
|
||||
const productName = str.slice(startIndex + 1, str.length)
|
||||
return {
|
||||
productId,
|
||||
productName: productName + `${(index == productIds.length - 1) ? '' : ','}`
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,10 +33,23 @@
|
|||
<el-radio :label="0">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="" v-if="form.useTime == 1" prop="saleTime">
|
||||
<el-time-picker is-range v-model="form.saleTime" value-format="HH:mm" format="HH:mm"
|
||||
range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" placeholder="选择时间范围">
|
||||
<el-form-item label="" v-if="form.useTime == 1">
|
||||
<!-- <el-time-picker is-range v-model="form.saleTime" value-format="HH:mm" format="HH:mm"
|
||||
:picker-options="pickerOptions" range-separator="至" start-placeholder="开始时间"
|
||||
end-placeholder="结束时间" placeholder="选择时间范围">
|
||||
</el-time-picker> -->
|
||||
|
||||
<el-time-picker placeholder="起始时间" v-model="form.saleStartTime" :picker-options="{
|
||||
selectableRange: '00:00:00 - 23:59:59',
|
||||
format: 'HH:mm'
|
||||
}" format="HH:mm" value-format="HH:mm">
|
||||
</el-time-picker>
|
||||
<el-time-picker placeholder="结束时间" v-model="form.saleEndTime" :picker-options="{
|
||||
selectableRange: '00:00:00 - 23:59:59',
|
||||
}" format="HH:mm" value-format="HH:mm">
|
||||
</el-time-picker>
|
||||
|
||||
|
||||
</el-form-item>
|
||||
<el-form-item label="分组排序" v-if="form.id">
|
||||
<el-input-number v-model="form.sort" controls-position="right" :min="0"></el-input-number>
|
||||
|
|
@ -44,7 +57,7 @@
|
|||
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button @click="quxiaodialogVisible">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="onSubmitHandle">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
|
@ -73,6 +86,15 @@ export default {
|
|||
useTime: 0,
|
||||
shopId: localStorage.getItem('shopId')
|
||||
},
|
||||
pickerOptions: {
|
||||
selectableRange: '00:00:00 - 23:59:59'
|
||||
// disabledDate(time) {
|
||||
// // return time.getTime() < Date.now() - 8.64e7;//如果没有后面的-8.64e7就是不可以选择今天的
|
||||
// // return time.getTime() < Date.now(); //只可以选择今天之后
|
||||
// return time.getTime() < Date.now() - 8.64e7;//只可以选择今天之后包括今天
|
||||
|
||||
// }
|
||||
},
|
||||
rules: {
|
||||
name: [
|
||||
{
|
||||
|
|
@ -93,6 +115,11 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
quxiaodialogVisible() {
|
||||
this.dialogVisible = false
|
||||
this.$emit('success', null)
|
||||
|
||||
},
|
||||
slectShop(res) {
|
||||
if (this.productIds.length) {
|
||||
res.map(async item => {
|
||||
|
|
@ -115,14 +142,12 @@ export default {
|
|||
return falg
|
||||
},
|
||||
onSubmitHandle() {
|
||||
console.log(this.form.saleTime)
|
||||
this.$refs.form.validate(async valid => {
|
||||
if (valid) {
|
||||
this.loading = true
|
||||
try {
|
||||
this.form.productIds = this.productIds.map(item => item.id);
|
||||
this.form.saleStartTime = this.form.saleTime[0]
|
||||
this.form.saleEndTime = this.form.saleTime[1]
|
||||
|
||||
let res = null
|
||||
if (!this.form.id) {
|
||||
await tbProductGroupPost(this.form)
|
||||
|
|
@ -152,6 +177,8 @@ export default {
|
|||
}
|
||||
},
|
||||
show(obj) {
|
||||
// if()
|
||||
this.form.useTime = 0
|
||||
if (obj && obj.id) {
|
||||
this.form = obj
|
||||
this.form.id = obj.id
|
||||
|
|
@ -159,12 +186,11 @@ export default {
|
|||
this.form.name = obj.name
|
||||
this.form.sort = obj.sort
|
||||
this.form.productIds = obj.productIds
|
||||
if (obj.saleStartTime != null) {
|
||||
this.$set(this.form, 'saleTime', [obj.saleStartTime, obj.saleEndTime])
|
||||
}
|
||||
// if (obj.saleStartTime != null) {
|
||||
// this.$set(this.form, 'saleTime', [obj.saleStartTime, obj.saleEndTime])
|
||||
// }
|
||||
this.getProduts()
|
||||
}
|
||||
|
||||
this.dialogVisible = true
|
||||
},
|
||||
close() {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,12 @@
|
|||
<el-table-column label="分组名称" prop="name"></el-table-column>
|
||||
<el-table-column label="售卖时间管控" prop="useTime">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.useTime==1? scope.row.saleStartTime +'-'+scope.row.saleEndTime:'' }}
|
||||
<template v-if="scope.row.useTime == 1">
|
||||
|
||||
<!-- {{ scope.row.saleStartTime + '-' + (scope.row.saleEndTime) }} -->
|
||||
{{ saleEndTimeFilter(scope.row.saleStartTime, scope.row.saleEndTime) }}
|
||||
<!-- {{ new Date(scope.row.saleEndTime+'').getTime() }} -->
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态">
|
||||
|
|
@ -66,8 +71,22 @@ export default {
|
|||
this.tableDrag()
|
||||
})
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
|
||||
},
|
||||
methods: {
|
||||
saleEndTimeFilter: (a, b) => {
|
||||
|
||||
var currentDate = new Date(); // 当前日期对象
|
||||
var dateString = currentDate.toDateString(); // 获取当前日期的字符串表示(不包含时分秒)
|
||||
var dateTimeString = dateString + ' ' + a; // 拼接日期和时分秒字符串
|
||||
var dateTimeStringb = dateString + ' ' + b; // 拼接日期和时分秒字符串
|
||||
var timestamp = Date.parse(dateTimeString); // 将日期时间字符串转换为时间戳
|
||||
var timestamp2 = Date.parse(dateTimeStringb); // 将日期时间字符串转换为时间戳
|
||||
let ciri = timestamp > timestamp2 ? '次日' : ''
|
||||
return a + ' - ' + ciri + b
|
||||
},
|
||||
//表格拖拽
|
||||
tableDrag() {
|
||||
const el = document.querySelector('#table_drag .el-table__body-wrapper tbody')
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ export default {
|
|||
}
|
||||
},
|
||||
async mounted() {
|
||||
console.log(this.$route.query.productId,'tiaoshi1')
|
||||
if (this.$route.query.productId) {
|
||||
this.query.productId = this.$route.query.productId
|
||||
}
|
||||
|
|
@ -206,11 +207,11 @@ export default {
|
|||
try {
|
||||
let localQuery = JSON.parse(localStorage.getItem('shopIndexQuery'))
|
||||
if (localQuery != null && localQuery.hasOwnProperty('productId')) {
|
||||
this.query = localQuery
|
||||
// this.query = localQuery
|
||||
}
|
||||
|
||||
this.tableData.loading = true
|
||||
console.log(this.query)
|
||||
console.log(this.query,'调试2')
|
||||
const res = await tbProduct({
|
||||
page: this.tableData.page,
|
||||
size: this.tableData.size,
|
||||
|
|
|
|||
Loading…
Reference in New Issue