Merge branch 'master' of https://gitee.com/darlk/ShengTangManage into xzj
This commit is contained in:
commit
6d77e6e07c
@ -10,6 +10,8 @@ import com.stdiet.custom.service.ISysRecipesService;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/custom/recipes")
|
@RequestMapping("/custom/recipes")
|
||||||
public class SysRecipesController extends BaseController {
|
public class SysRecipesController extends BaseController {
|
||||||
@ -39,6 +41,11 @@ public class SysRecipesController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = "/menu/replace")
|
||||||
|
public AjaxResult replaceMenu(@RequestBody List<SysRecipesDailyDishes> dishes) {
|
||||||
|
return AjaxResult.success(sysRecipesService.replaceDishes(dishes));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改食谱菜品
|
* 修改食谱菜品
|
||||||
*
|
*
|
||||||
|
@ -26,5 +26,7 @@ public interface SysRecipesMapper {
|
|||||||
|
|
||||||
public int deleteDishes(Long id);
|
public int deleteDishes(Long id);
|
||||||
|
|
||||||
|
public int deleteMenu(Long id);
|
||||||
|
|
||||||
public List<SysRecipesDailyDishes> selectDishesByMenuId(Long id);
|
public List<SysRecipesDailyDishes> selectDishesByMenuId(Long id);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.stdiet.custom.domain.SysRecipes;
|
|||||||
import com.stdiet.custom.domain.SysRecipesDaily;
|
import com.stdiet.custom.domain.SysRecipesDaily;
|
||||||
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
||||||
|
|
||||||
|
import java.sql.Array;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface ISysRecipesService {
|
public interface ISysRecipesService {
|
||||||
@ -20,4 +21,6 @@ public interface ISysRecipesService {
|
|||||||
|
|
||||||
public int deleteDishes(Long id);
|
public int deleteDishes(Long id);
|
||||||
|
|
||||||
|
public Long[] replaceDishes(List<SysRecipesDailyDishes> sysRecipesDailyDishes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.stdiet.custom.service.impl;
|
package com.stdiet.custom.service.impl;
|
||||||
|
|
||||||
import com.stdiet.common.utils.StringUtils;
|
|
||||||
import com.stdiet.custom.domain.SysRecipes;
|
import com.stdiet.custom.domain.SysRecipes;
|
||||||
import com.stdiet.custom.domain.SysRecipesDaily;
|
import com.stdiet.custom.domain.SysRecipesDaily;
|
||||||
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
||||||
@ -62,6 +61,7 @@ public class SysRecipesServiceImpl implements ISysRecipesService {
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysRecipes> selectSysRecipesByRecipesId(Long id) {
|
public List<SysRecipes> selectSysRecipesByRecipesId(Long id) {
|
||||||
return sysRecipesMapper.selectSysRecipesByRecipesId(id);
|
return sysRecipesMapper.selectSysRecipesByRecipesId(id);
|
||||||
@ -86,4 +86,20 @@ public class SysRecipesServiceImpl implements ISysRecipesService {
|
|||||||
public int deleteDishes(Long id) {
|
public int deleteDishes(Long id) {
|
||||||
return sysRecipesMapper.deleteDishes(id);
|
return sysRecipesMapper.deleteDishes(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long[] replaceDishes(List<SysRecipesDailyDishes> sysRecipesDailyDishes) {
|
||||||
|
// 删除原有
|
||||||
|
sysRecipesMapper.deleteMenu(sysRecipesDailyDishes.get(0).getMenuId());
|
||||||
|
// 插入新的
|
||||||
|
int row = sysRecipesMapper.bashAddDishes(sysRecipesDailyDishes);
|
||||||
|
if (row > 0) {
|
||||||
|
Long[] ids = new Long[sysRecipesDailyDishes.size()];
|
||||||
|
for (int i = 0; i < sysRecipesDailyDishes.size(); i++) {
|
||||||
|
ids[i] = sysRecipesDailyDishes.get(i).getId();
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,11 @@
|
|||||||
delete from sys_customer_menu_dishes where id = #{id}
|
delete from sys_customer_menu_dishes where id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<!-- 删除整天食谱 -->
|
||||||
|
<delete id="deleteMenu" parameterType="Long">
|
||||||
|
delete from sys_customer_menu_dishes where menu_id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
<!-- 查询已有食谱天数-->
|
<!-- 查询已有食谱天数-->
|
||||||
<select id="getNumDayByCusId" parameterType="Long" resultType="Integer">
|
<select id="getNumDayByCusId" parameterType="Long" resultType="Integer">
|
||||||
select count(*) from sys_customer_daily_menu where cus_id = #{id}
|
select count(*) from sys_customer_daily_menu where cus_id = #{id}
|
||||||
@ -141,7 +146,7 @@
|
|||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<!-- 新增菜单对应菜品-->
|
<!-- 新增菜单对应菜品-->
|
||||||
<insert id="bashAddDishes" >
|
<insert id="bashAddDishes" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into sys_customer_menu_dishes (menu_id, type, dishes_id, remark, detail) values
|
insert into sys_customer_menu_dishes (menu_id, type, dishes_id, remark, detail) values
|
||||||
<foreach collection="list" separator="," item="item" index="index">
|
<foreach collection="list" separator="," item="item" index="index">
|
||||||
(#{item.menuId}, #{item.type}, #{item.dishesId}, #{item.remark}, #{item.detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler})
|
(#{item.menuId}, #{item.type}, #{item.dishesId}, #{item.remark}, #{item.detail, jdbcType=OTHER, typeHandler=com.stdiet.custom.typehandler.ArrayJsonHandler})
|
||||||
|
@ -37,3 +37,11 @@ export function deleteDishesApi(id) {
|
|||||||
method: "delete"
|
method: "delete"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function replaceMenuApi(data) {
|
||||||
|
return request({
|
||||||
|
url: "/custom/recipes/menu/replace",
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -45,7 +45,7 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value(val) {
|
value(val) {
|
||||||
console.log(val);
|
// console.log(val);
|
||||||
this.nData = val;
|
this.nData = val;
|
||||||
},
|
},
|
||||||
nData(val) {
|
nData(val) {
|
||||||
|
@ -194,7 +194,7 @@ export default {
|
|||||||
}
|
}
|
||||||
if (idx === res.rows.length - 1) {
|
if (idx === res.rows.length - 1) {
|
||||||
arr.forEach((obj) => {
|
arr.forEach((obj) => {
|
||||||
console.log({ obj });
|
// console.log({ obj });
|
||||||
if (obj.children) {
|
if (obj.children) {
|
||||||
obj.amount = obj.children.reduce(
|
obj.amount = obj.children.reduce(
|
||||||
(a, c) => a + (c.afterSaleCommissOrder === 0 ? c.amount : 0),
|
(a, c) => a + (c.afterSaleCommissOrder === 0 ? c.amount : 0),
|
||||||
@ -205,7 +205,7 @@ export default {
|
|||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}, []);
|
}, []);
|
||||||
console.log(this.orderList);
|
// console.log(this.orderList);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -52,7 +52,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showDialog(data, healthy, type) {
|
showDialog(data, healthy, type) {
|
||||||
console.log(healthy)
|
// console.log(healthy)
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.title = "修改" + `「${data.name}」` + "备注";
|
this.title = "修改" + `「${data.name}」` + "备注";
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
{{ `${scope.row.startDate} 至 ${scope.row.endDate}` }}
|
{{ `${scope.row.startDate} 至 ${scope.row.endDate}` }}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="发送" align="center">
|
<el-table-column label="发送" align="center" width="80">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="!!scope.row.sendFlag"
|
v-model="!!scope.row.sendFlag"
|
||||||
|
@ -5,12 +5,15 @@ import {
|
|||||||
updateDishesDetailApi,
|
updateDishesDetailApi,
|
||||||
addDishesApi,
|
addDishesApi,
|
||||||
deleteDishesApi,
|
deleteDishesApi,
|
||||||
addRecipesApi
|
addRecipesApi,
|
||||||
|
replaceMenuApi
|
||||||
} from "@/api/custom/recipes";
|
} from "@/api/custom/recipes";
|
||||||
import { getDishesMenuTypes } from "@/api/custom/dishes";
|
import { getDishesMenuTypes } from "@/api/custom/dishes";
|
||||||
import { getRecipesTemplateDetail } from "@/api/custom/recipesTemplate";
|
import { getRecipesTemplateDetail } from "@/api/custom/recipesTemplate";
|
||||||
import { getRecipesPlan, updateRecipesPlan } from "@/api/custom/recipesPlan";
|
import { getRecipesPlan, updateRecipesPlan } from "@/api/custom/recipesPlan";
|
||||||
import { getDicts } from "@/api/system/dict/data";
|
import { getDicts } from "@/api/system/dict/data";
|
||||||
|
import { addShortCut } from "@/utils/shortCutUtils";
|
||||||
|
import { messageTypes } from "@/utils";
|
||||||
|
|
||||||
const oriState = {
|
const oriState = {
|
||||||
cusId: undefined,
|
cusId: undefined,
|
||||||
@ -31,8 +34,10 @@ const oriState = {
|
|||||||
endNum: 0,
|
endNum: 0,
|
||||||
reviewStatus: 0,
|
reviewStatus: 0,
|
||||||
templateInfo: undefined,
|
templateInfo: undefined,
|
||||||
copyData: undefined,
|
//
|
||||||
canCopyMenuTypes: [],
|
// copyData: undefined,
|
||||||
|
// canCopyMenuTypes: [],
|
||||||
|
//
|
||||||
fontSize: parseInt(localStorage.getItem("fontSize")) || 12,
|
fontSize: parseInt(localStorage.getItem("fontSize")) || 12,
|
||||||
dishBigClassOptions: [],
|
dishBigClassOptions: [],
|
||||||
dishSmallClassOptions: [],
|
dishSmallClassOptions: [],
|
||||||
@ -40,7 +45,9 @@ const oriState = {
|
|||||||
leftShow: false,
|
leftShow: false,
|
||||||
notRecIgds: [],
|
notRecIgds: [],
|
||||||
avoidFoodIds: [],
|
avoidFoodIds: [],
|
||||||
igdTypeOptions: []
|
igdTypeOptions: [],
|
||||||
|
//
|
||||||
|
curShortCutObj: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
@ -113,6 +120,9 @@ const mutations = {
|
|||||||
setNotRecIgds(state, payload) {
|
setNotRecIgds(state, payload) {
|
||||||
state.notRecIgds = payload.data;
|
state.notRecIgds = payload.data;
|
||||||
},
|
},
|
||||||
|
setCurShortCutObj(state, payload) {
|
||||||
|
state.curShortCutObj = payload.data;
|
||||||
|
},
|
||||||
setDate(state, payload) {
|
setDate(state, payload) {
|
||||||
state.startDate = payload.startDate;
|
state.startDate = payload.startDate;
|
||||||
state.endDate = payload.endDate;
|
state.endDate = payload.endDate;
|
||||||
@ -461,6 +471,45 @@ const actions = {
|
|||||||
commit("deleteSomeDayDishes", payload);
|
commit("deleteSomeDayDishes", payload);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async replaceMenu({ commit, state }, payload) {
|
||||||
|
const rData = JSON.parse(JSON.stringify(state.recipesData));
|
||||||
|
if (state.recipesId) {
|
||||||
|
const tarData = {
|
||||||
|
...payload.data,
|
||||||
|
dishes: payload.data.dishes.map(obj => ({
|
||||||
|
...obj,
|
||||||
|
id: -1
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
const menuData = payload.data.dishes.map(dObj => ({
|
||||||
|
menuId: payload.data.id,
|
||||||
|
dishesId: dObj.dishesId,
|
||||||
|
type: dObj.type,
|
||||||
|
remark: dObj.remark,
|
||||||
|
detail: dObj.igdList.map(igd => ({
|
||||||
|
id: igd.id,
|
||||||
|
weight: igd.weight,
|
||||||
|
cus_unit: igd.cusUnit,
|
||||||
|
cus_weight: igd.cusWeight
|
||||||
|
}))
|
||||||
|
}));
|
||||||
|
const result = await replaceMenuApi(menuData);
|
||||||
|
if (result.code === 200) {
|
||||||
|
result.data.forEach((id, idx) => {
|
||||||
|
tarData.dishes[idx].id = id;
|
||||||
|
});
|
||||||
|
rData[payload.num] = tarData;
|
||||||
|
commit("updateStateData", {
|
||||||
|
recipesData: rData
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rData[payload.num] = payload.data;
|
||||||
|
commit("updateStateData", {
|
||||||
|
recipesData: rData
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
async deleteMenu({ commit }, payload) {},
|
async deleteMenu({ commit }, payload) {},
|
||||||
async setCopyData({ commit, state }, payload) {
|
async setCopyData({ commit, state }, payload) {
|
||||||
return new Promise(async (res, rej) => {
|
return new Promise(async (res, rej) => {
|
||||||
@ -470,16 +519,29 @@ const actions = {
|
|||||||
if (tarDishes) {
|
if (tarDishes) {
|
||||||
const response = await getDishesMenuTypes(tarDishes.dishesId);
|
const response = await getDishesMenuTypes(tarDishes.dishesId);
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
commit("updateStateData", {
|
// commit("updateStateData", {
|
||||||
copyData: tarDishes,
|
// copyData: tarDishes,
|
||||||
canCopyMenuTypes: response.data.type.split(",")
|
// canCopyMenuTypes: type
|
||||||
|
// });
|
||||||
|
addShortCut({
|
||||||
|
id: new Date().getTime(),
|
||||||
|
name: tarDishes.name,
|
||||||
|
type: response.data.type.split(",").sort(),
|
||||||
|
data: tarDishes
|
||||||
|
}).then(() => {
|
||||||
|
window.postMessage(
|
||||||
|
{
|
||||||
|
type: messageTypes.UPDATE_SHORTCUT
|
||||||
|
},
|
||||||
|
"*"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
res("复制成功");
|
res("添加成功");
|
||||||
} else {
|
} else {
|
||||||
rej("复制失败");
|
rej("添加失败");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rej("复制失败");
|
rej("添加失败");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
import { parseTime } from './ruoyi'
|
import { parseTime } from "./ruoyi";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格时间格式化
|
* 表格时间格式化
|
||||||
*/
|
*/
|
||||||
export function formatDate(cellValue) {
|
export function formatDate(cellValue) {
|
||||||
if (cellValue == null || cellValue == "") return "";
|
if (cellValue == null || cellValue == "") return "";
|
||||||
var date = new Date(cellValue)
|
var date = new Date(cellValue);
|
||||||
var year = date.getFullYear()
|
var year = date.getFullYear();
|
||||||
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
var month =
|
||||||
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
date.getMonth() + 1 < 10
|
||||||
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
|
? "0" + (date.getMonth() + 1)
|
||||||
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
: date.getMonth() + 1;
|
||||||
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
|
var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
||||||
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
|
var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
||||||
|
var minutes =
|
||||||
|
date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
||||||
|
var seconds =
|
||||||
|
date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
||||||
|
return (
|
||||||
|
year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,40 +28,40 @@ export function formatDate(cellValue) {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function formatTime(time, option) {
|
export function formatTime(time, option) {
|
||||||
if (('' + time).length === 10) {
|
if (("" + time).length === 10) {
|
||||||
time = parseInt(time) * 1000
|
time = parseInt(time) * 1000;
|
||||||
} else {
|
} else {
|
||||||
time = +time
|
time = +time;
|
||||||
}
|
}
|
||||||
const d = new Date(time)
|
const d = new Date(time);
|
||||||
const now = Date.now()
|
const now = Date.now();
|
||||||
|
|
||||||
const diff = (now - d) / 1000
|
const diff = (now - d) / 1000;
|
||||||
|
|
||||||
if (diff < 30) {
|
if (diff < 30) {
|
||||||
return '刚刚'
|
return "刚刚";
|
||||||
} else if (diff < 3600) {
|
} else if (diff < 3600) {
|
||||||
// less 1 hour
|
// less 1 hour
|
||||||
return Math.ceil(diff / 60) + '分钟前'
|
return Math.ceil(diff / 60) + "分钟前";
|
||||||
} else if (diff < 3600 * 24) {
|
} else if (diff < 3600 * 24) {
|
||||||
return Math.ceil(diff / 3600) + '小时前'
|
return Math.ceil(diff / 3600) + "小时前";
|
||||||
} else if (diff < 3600 * 24 * 2) {
|
} else if (diff < 3600 * 24 * 2) {
|
||||||
return '1天前'
|
return "1天前";
|
||||||
}
|
}
|
||||||
if (option) {
|
if (option) {
|
||||||
return parseTime(time, option)
|
return parseTime(time, option);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
d.getMonth() +
|
d.getMonth() +
|
||||||
1 +
|
1 +
|
||||||
'月' +
|
"月" +
|
||||||
d.getDate() +
|
d.getDate() +
|
||||||
'日' +
|
"日" +
|
||||||
d.getHours() +
|
d.getHours() +
|
||||||
'时' +
|
"时" +
|
||||||
d.getMinutes() +
|
d.getMinutes() +
|
||||||
'分'
|
"分"
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,18 +70,18 @@ export function formatTime(time, option) {
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function getQueryObject(url) {
|
export function getQueryObject(url) {
|
||||||
url = url == null ? window.location.href : url
|
url = url == null ? window.location.href : url;
|
||||||
const search = url.substring(url.lastIndexOf('?') + 1)
|
const search = url.substring(url.lastIndexOf("?") + 1);
|
||||||
const obj = {}
|
const obj = {};
|
||||||
const reg = /([^?&=]+)=([^?&=]*)/g
|
const reg = /([^?&=]+)=([^?&=]*)/g;
|
||||||
search.replace(reg, (rs, $1, $2) => {
|
search.replace(reg, (rs, $1, $2) => {
|
||||||
const name = decodeURIComponent($1)
|
const name = decodeURIComponent($1);
|
||||||
let val = decodeURIComponent($2)
|
let val = decodeURIComponent($2);
|
||||||
val = String(val)
|
val = String(val);
|
||||||
obj[name] = val
|
obj[name] = val;
|
||||||
return rs
|
return rs;
|
||||||
})
|
});
|
||||||
return obj
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,14 +90,14 @@ export function getQueryObject(url) {
|
|||||||
*/
|
*/
|
||||||
export function byteLength(str) {
|
export function byteLength(str) {
|
||||||
// returns the byte length of an utf8 string
|
// returns the byte length of an utf8 string
|
||||||
let s = str.length
|
let s = str.length;
|
||||||
for (var i = str.length - 1; i >= 0; i--) {
|
for (var i = str.length - 1; i >= 0; i--) {
|
||||||
const code = str.charCodeAt(i)
|
const code = str.charCodeAt(i);
|
||||||
if (code > 0x7f && code <= 0x7ff) s++
|
if (code > 0x7f && code <= 0x7ff) s++;
|
||||||
else if (code > 0x7ff && code <= 0xffff) s += 2
|
else if (code > 0x7ff && code <= 0xffff) s += 2;
|
||||||
if (code >= 0xDC00 && code <= 0xDFFF) i--
|
if (code >= 0xdc00 && code <= 0xdfff) i--;
|
||||||
}
|
}
|
||||||
return s
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,13 +105,13 @@ export function byteLength(str) {
|
|||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
export function cleanArray(actual) {
|
export function cleanArray(actual) {
|
||||||
const newArray = []
|
const newArray = [];
|
||||||
for (let i = 0; i < actual.length; i++) {
|
for (let i = 0; i < actual.length; i++) {
|
||||||
if (actual[i]) {
|
if (actual[i]) {
|
||||||
newArray.push(actual[i])
|
newArray.push(actual[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newArray
|
return newArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,13 +119,13 @@ export function cleanArray(actual) {
|
|||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
export function param(json) {
|
export function param(json) {
|
||||||
if (!json) return ''
|
if (!json) return "";
|
||||||
return cleanArray(
|
return cleanArray(
|
||||||
Object.keys(json).map(key => {
|
Object.keys(json).map(key => {
|
||||||
if (json[key] === undefined) return ''
|
if (json[key] === undefined) return "";
|
||||||
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
|
return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
|
||||||
})
|
})
|
||||||
).join('&')
|
).join("&");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,21 +133,21 @@ export function param(json) {
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function param2Obj(url) {
|
export function param2Obj(url) {
|
||||||
const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
|
const search = decodeURIComponent(url.split("?")[1]).replace(/\+/g, " ");
|
||||||
if (!search) {
|
if (!search) {
|
||||||
return {}
|
return {};
|
||||||
}
|
}
|
||||||
const obj = {}
|
const obj = {};
|
||||||
const searchArr = search.split('&')
|
const searchArr = search.split("&");
|
||||||
searchArr.forEach(v => {
|
searchArr.forEach(v => {
|
||||||
const index = v.indexOf('=')
|
const index = v.indexOf("=");
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
const name = v.substring(0, index)
|
const name = v.substring(0, index);
|
||||||
const val = v.substring(index + 1, v.length)
|
const val = v.substring(index + 1, v.length);
|
||||||
obj[name] = val
|
obj[name] = val;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return obj
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -148,9 +155,9 @@ export function param2Obj(url) {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function html2Text(val) {
|
export function html2Text(val) {
|
||||||
const div = document.createElement('div')
|
const div = document.createElement("div");
|
||||||
div.innerHTML = val
|
div.innerHTML = val;
|
||||||
return div.textContent || div.innerText
|
return div.textContent || div.innerText;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,21 +167,21 @@ export function html2Text(val) {
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function objectMerge(target, source) {
|
export function objectMerge(target, source) {
|
||||||
if (typeof target !== 'object') {
|
if (typeof target !== "object") {
|
||||||
target = {}
|
target = {};
|
||||||
}
|
}
|
||||||
if (Array.isArray(source)) {
|
if (Array.isArray(source)) {
|
||||||
return source.slice()
|
return source.slice();
|
||||||
}
|
}
|
||||||
Object.keys(source).forEach(property => {
|
Object.keys(source).forEach(property => {
|
||||||
const sourceProperty = source[property]
|
const sourceProperty = source[property];
|
||||||
if (typeof sourceProperty === 'object') {
|
if (typeof sourceProperty === "object") {
|
||||||
target[property] = objectMerge(target[property], sourceProperty)
|
target[property] = objectMerge(target[property], sourceProperty);
|
||||||
} else {
|
} else {
|
||||||
target[property] = sourceProperty
|
target[property] = sourceProperty;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return target
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,18 +190,18 @@ export function objectMerge(target, source) {
|
|||||||
*/
|
*/
|
||||||
export function toggleClass(element, className) {
|
export function toggleClass(element, className) {
|
||||||
if (!element || !className) {
|
if (!element || !className) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let classString = element.className
|
let classString = element.className;
|
||||||
const nameIndex = classString.indexOf(className)
|
const nameIndex = classString.indexOf(className);
|
||||||
if (nameIndex === -1) {
|
if (nameIndex === -1) {
|
||||||
classString += '' + className
|
classString += "" + className;
|
||||||
} else {
|
} else {
|
||||||
classString =
|
classString =
|
||||||
classString.substr(0, nameIndex) +
|
classString.substr(0, nameIndex) +
|
||||||
classString.substr(nameIndex + className.length)
|
classString.substr(nameIndex + className.length);
|
||||||
}
|
}
|
||||||
element.className = classString
|
element.className = classString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,10 +209,10 @@ export function toggleClass(element, className) {
|
|||||||
* @returns {Date}
|
* @returns {Date}
|
||||||
*/
|
*/
|
||||||
export function getTime(type) {
|
export function getTime(type) {
|
||||||
if (type === 'start') {
|
if (type === "start") {
|
||||||
return new Date().getTime() - 3600 * 1000 * 24 * 90
|
return new Date().getTime() - 3600 * 1000 * 24 * 90;
|
||||||
} else {
|
} else {
|
||||||
return new Date(new Date().toDateString())
|
return new Date(new Date().toDateString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,38 +223,38 @@ export function getTime(type) {
|
|||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
export function debounce(func, wait, immediate) {
|
export function debounce(func, wait, immediate) {
|
||||||
let timeout, args, context, timestamp, result
|
let timeout, args, context, timestamp, result;
|
||||||
|
|
||||||
const later = function() {
|
const later = function() {
|
||||||
// 据上一次触发时间间隔
|
// 据上一次触发时间间隔
|
||||||
const last = +new Date() - timestamp
|
const last = +new Date() - timestamp;
|
||||||
|
|
||||||
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
||||||
if (last < wait && last > 0) {
|
if (last < wait && last > 0) {
|
||||||
timeout = setTimeout(later, wait - last)
|
timeout = setTimeout(later, wait - last);
|
||||||
} else {
|
} else {
|
||||||
timeout = null
|
timeout = null;
|
||||||
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
||||||
if (!immediate) {
|
if (!immediate) {
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args);
|
||||||
if (!timeout) context = args = null
|
if (!timeout) context = args = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
return function(...args) {
|
return function(...args) {
|
||||||
context = this
|
context = this;
|
||||||
timestamp = +new Date()
|
timestamp = +new Date();
|
||||||
const callNow = immediate && !timeout
|
const callNow = immediate && !timeout;
|
||||||
// 如果延时不存在,重新设定延时
|
// 如果延时不存在,重新设定延时
|
||||||
if (!timeout) timeout = setTimeout(later, wait)
|
if (!timeout) timeout = setTimeout(later, wait);
|
||||||
if (callNow) {
|
if (callNow) {
|
||||||
result = func.apply(context, args)
|
result = func.apply(context, args);
|
||||||
context = args = null
|
context = args = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -258,18 +265,18 @@ export function debounce(func, wait, immediate) {
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
export function deepClone(source) {
|
export function deepClone(source) {
|
||||||
if (!source && typeof source !== 'object') {
|
if (!source && typeof source !== "object") {
|
||||||
throw new Error('error arguments', 'deepClone')
|
throw new Error("error arguments", "deepClone");
|
||||||
}
|
}
|
||||||
const targetObj = source.constructor === Array ? [] : {}
|
const targetObj = source.constructor === Array ? [] : {};
|
||||||
Object.keys(source).forEach(keys => {
|
Object.keys(source).forEach(keys => {
|
||||||
if (source[keys] && typeof source[keys] === 'object') {
|
if (source[keys] && typeof source[keys] === "object") {
|
||||||
targetObj[keys] = deepClone(source[keys])
|
targetObj[keys] = deepClone(source[keys]);
|
||||||
} else {
|
} else {
|
||||||
targetObj[keys] = source[keys]
|
targetObj[keys] = source[keys];
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
return targetObj
|
return targetObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -277,16 +284,16 @@ export function deepClone(source) {
|
|||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
export function uniqueArr(arr) {
|
export function uniqueArr(arr) {
|
||||||
return Array.from(new Set(arr))
|
return Array.from(new Set(arr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function createUniqueString() {
|
export function createUniqueString() {
|
||||||
const timestamp = +new Date() + ''
|
const timestamp = +new Date() + "";
|
||||||
const randomNum = parseInt((1 + Math.random()) * 65536) + ''
|
const randomNum = parseInt((1 + Math.random()) * 65536) + "";
|
||||||
return (+(randomNum + timestamp)).toString(32)
|
return (+(randomNum + timestamp)).toString(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -296,7 +303,7 @@ export function createUniqueString() {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
export function hasClass(ele, cls) {
|
export function hasClass(ele, cls) {
|
||||||
return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
|
return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -305,7 +312,7 @@ export function hasClass(ele, cls) {
|
|||||||
* @param {string} cls
|
* @param {string} cls
|
||||||
*/
|
*/
|
||||||
export function addClass(ele, cls) {
|
export function addClass(ele, cls) {
|
||||||
if (!hasClass(ele, cls)) ele.className += ' ' + cls
|
if (!hasClass(ele, cls)) ele.className += " " + cls;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -315,76 +322,78 @@ export function addClass(ele, cls) {
|
|||||||
*/
|
*/
|
||||||
export function removeClass(ele, cls) {
|
export function removeClass(ele, cls) {
|
||||||
if (hasClass(ele, cls)) {
|
if (hasClass(ele, cls)) {
|
||||||
const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
|
const reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
|
||||||
ele.className = ele.className.replace(reg, ' ')
|
ele.className = ele.className.replace(reg, " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function makeMap(str, expectsLowerCase) {
|
export function makeMap(str, expectsLowerCase) {
|
||||||
const map = Object.create(null)
|
const map = Object.create(null);
|
||||||
const list = str.split(',')
|
const list = str.split(",");
|
||||||
for (let i = 0; i < list.length; i++) {
|
for (let i = 0; i < list.length; i++) {
|
||||||
map[list[i]] = true
|
map[list[i]] = true;
|
||||||
}
|
}
|
||||||
return expectsLowerCase
|
return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val];
|
||||||
? val => map[val.toLowerCase()]
|
|
||||||
: val => map[val]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const exportDefault = 'export default '
|
export const exportDefault = "export default ";
|
||||||
|
|
||||||
export const beautifierConf = {
|
export const beautifierConf = {
|
||||||
html: {
|
html: {
|
||||||
indent_size: '2',
|
indent_size: "2",
|
||||||
indent_char: ' ',
|
indent_char: " ",
|
||||||
max_preserve_newlines: '-1',
|
max_preserve_newlines: "-1",
|
||||||
preserve_newlines: false,
|
preserve_newlines: false,
|
||||||
keep_array_indentation: false,
|
keep_array_indentation: false,
|
||||||
break_chained_methods: false,
|
break_chained_methods: false,
|
||||||
indent_scripts: 'separate',
|
indent_scripts: "separate",
|
||||||
brace_style: 'end-expand',
|
brace_style: "end-expand",
|
||||||
space_before_conditional: true,
|
space_before_conditional: true,
|
||||||
unescape_strings: false,
|
unescape_strings: false,
|
||||||
jslint_happy: false,
|
jslint_happy: false,
|
||||||
end_with_newline: true,
|
end_with_newline: true,
|
||||||
wrap_line_length: '110',
|
wrap_line_length: "110",
|
||||||
indent_inner_html: true,
|
indent_inner_html: true,
|
||||||
comma_first: false,
|
comma_first: false,
|
||||||
e4x: true,
|
e4x: true,
|
||||||
indent_empty_lines: true
|
indent_empty_lines: true
|
||||||
},
|
},
|
||||||
js: {
|
js: {
|
||||||
indent_size: '2',
|
indent_size: "2",
|
||||||
indent_char: ' ',
|
indent_char: " ",
|
||||||
max_preserve_newlines: '-1',
|
max_preserve_newlines: "-1",
|
||||||
preserve_newlines: false,
|
preserve_newlines: false,
|
||||||
keep_array_indentation: false,
|
keep_array_indentation: false,
|
||||||
break_chained_methods: false,
|
break_chained_methods: false,
|
||||||
indent_scripts: 'normal',
|
indent_scripts: "normal",
|
||||||
brace_style: 'end-expand',
|
brace_style: "end-expand",
|
||||||
space_before_conditional: true,
|
space_before_conditional: true,
|
||||||
unescape_strings: false,
|
unescape_strings: false,
|
||||||
jslint_happy: true,
|
jslint_happy: true,
|
||||||
end_with_newline: true,
|
end_with_newline: true,
|
||||||
wrap_line_length: '110',
|
wrap_line_length: "110",
|
||||||
indent_inner_html: true,
|
indent_inner_html: true,
|
||||||
comma_first: false,
|
comma_first: false,
|
||||||
e4x: true,
|
e4x: true,
|
||||||
indent_empty_lines: true
|
indent_empty_lines: true
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// 首字母大小
|
// 首字母大小
|
||||||
export function titleCase(str) {
|
export function titleCase(str) {
|
||||||
return str.replace(/( |^)[a-z]/g, L => L.toUpperCase())
|
return str.replace(/( |^)[a-z]/g, L => L.toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下划转驼峰
|
// 下划转驼峰
|
||||||
export function camelCase(str) {
|
export function camelCase(str) {
|
||||||
return str.replace(/-[a-z]/g, str1 => str1.substr(-1).toUpperCase())
|
return str.replace(/-[a-z]/g, str1 => str1.substr(-1).toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isNumberStr(str) {
|
export function isNumberStr(str) {
|
||||||
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
|
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const messageTypes = {
|
||||||
|
UPDATE_SHORTCUT: "updateShortCut",
|
||||||
|
UPDATE_CURRENT_SHORTCUT: "updateCurrentShortCut"
|
||||||
|
};
|
||||||
|
52
stdiet-ui/src/utils/shortCutUtils.js
Normal file
52
stdiet-ui/src/utils/shortCutUtils.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
export function getShortCut() {
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
try {
|
||||||
|
const data = JSON.parse(localStorage.getItem("shortCut") || "[]");
|
||||||
|
res(data);
|
||||||
|
} catch (error) {
|
||||||
|
rej(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function addShortCut(data) {
|
||||||
|
const shortCutList = await getShortCut();
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
try {
|
||||||
|
shortCutList.splice(0, 0, data);
|
||||||
|
localStorage.setItem("shortCut", JSON.stringify(shortCutList));
|
||||||
|
res();
|
||||||
|
} catch (error) {
|
||||||
|
rej(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function removeShortCut(id) {
|
||||||
|
const shortCutList = await getShortCut();
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
try {
|
||||||
|
const newShortCutList = shortCutList.filter(obj => obj.id !== id);
|
||||||
|
localStorage.setItem("shortCut", JSON.stringify(newShortCutList));
|
||||||
|
res();
|
||||||
|
} catch (error) {
|
||||||
|
rej(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editShortCut(data) {
|
||||||
|
const shortCutList = await getShortCut();
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
try {
|
||||||
|
const tarObj = shortCutList.find(obj => obj.id === data.id);
|
||||||
|
Object.keys(data).forEach(key => {
|
||||||
|
tarObj[key] = data[key];
|
||||||
|
});
|
||||||
|
localStorage.setItem("shortCut", JSON.stringify(shortCutList));
|
||||||
|
res();
|
||||||
|
} catch (error) {
|
||||||
|
rej(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,191 @@
|
|||||||
|
<template>
|
||||||
|
<div class="short_cut_com_wrapper">
|
||||||
|
<div class="header">
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="getList" circle />
|
||||||
|
</div>
|
||||||
|
<el-table
|
||||||
|
:data="dataList"
|
||||||
|
ref="shortCutTable"
|
||||||
|
highlight-current-row
|
||||||
|
@current-change="handleOnCurrentChange"
|
||||||
|
height="800"
|
||||||
|
>
|
||||||
|
<el-table-column prop="name" label="对象" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-popover
|
||||||
|
placement="left"
|
||||||
|
width="200"
|
||||||
|
trigger="click"
|
||||||
|
title="修改对象名称"
|
||||||
|
@hide="handleOnHide"
|
||||||
|
>
|
||||||
|
<el-input
|
||||||
|
v-model="scope.row.name"
|
||||||
|
@change="(val) => handleOnNameChange(val, scope.row)"
|
||||||
|
/>
|
||||||
|
<span slot="reference" style="cursor: pointer">
|
||||||
|
{{ scope.row.name }}
|
||||||
|
</span>
|
||||||
|
</el-popover>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="type" label="可用类型" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<AutoHideInfo :data="translateType(scope.row.type)" :line="10" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="priview" label="预览" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-popover
|
||||||
|
placement="left"
|
||||||
|
trigger="click"
|
||||||
|
:title="`「${scope.row.name}」预览`"
|
||||||
|
>
|
||||||
|
<!-- 菜谱预览 -->
|
||||||
|
<RecipesCom
|
||||||
|
v-if="scope.row.type.includes('0')"
|
||||||
|
:data="scope.row.data"
|
||||||
|
:numDay="scope.row.data.numDay"
|
||||||
|
preview
|
||||||
|
/>
|
||||||
|
<!-- 菜品预览 -->
|
||||||
|
<el-table border :data="scope.row.data.igdList" v-else size="mini">
|
||||||
|
<el-table-column align="center" label="食材" prop="name" />
|
||||||
|
<el-table-column align="center" label="分量估算">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{
|
||||||
|
`${cusWeightDict[scope.row.cusWeight]}${
|
||||||
|
cusUnitDict[scope.row.cusUnit]
|
||||||
|
}`
|
||||||
|
}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center" label="重量(g)" prop="weight" />
|
||||||
|
</el-table>
|
||||||
|
<el-button type="text" size="mini" slot="reference">预览</el-button>
|
||||||
|
</el-popover>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" :width="60" align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" size="mini" @click="handleOnDelete(scope.row)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
getShortCut,
|
||||||
|
removeShortCut,
|
||||||
|
editShortCut,
|
||||||
|
} from "@/utils/shortCutUtils";
|
||||||
|
import AutoHideInfo from "@/components/AutoHideInfo";
|
||||||
|
import { createNamespacedHelpers } from "vuex";
|
||||||
|
import RecipesCom from "../../RecipesView/RecipesCom";
|
||||||
|
const { mapState, mapMutations, mapGetters } = createNamespacedHelpers(
|
||||||
|
"recipes"
|
||||||
|
);
|
||||||
|
import { messageTypes } from "@/utils";
|
||||||
|
export default {
|
||||||
|
name: "ShortCutCom",
|
||||||
|
components: {
|
||||||
|
AutoHideInfo,
|
||||||
|
RecipesCom,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dataList: [],
|
||||||
|
modifingId: 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
window.addEventListener("storage", this.storageListener);
|
||||||
|
window.addEventListener("message", this.messageListener);
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
window.removeEventListener("storage", this.storageListener);
|
||||||
|
window.removeEventListener("message", this.messageListener);
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
names() {
|
||||||
|
return this.dataList.map((obj) => obj.name);
|
||||||
|
},
|
||||||
|
...mapState(["curShortCutObj"]),
|
||||||
|
...mapGetters(["cusUnitDict", "cusWeightDict"]),
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
storageListener(e) {
|
||||||
|
const { key } = e;
|
||||||
|
if (key === "shortCut") {
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
messageListener(e) {
|
||||||
|
const { data } = e;
|
||||||
|
if (data.type === messageTypes.UPDATE_SHORTCUT) {
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getList() {
|
||||||
|
getShortCut().then((data) => {
|
||||||
|
this.dataList = data;
|
||||||
|
// console.log(this.dataList);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleOnDelete(data) {
|
||||||
|
removeShortCut(data.id).then((res) => {
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleOnCurrentChange(data) {
|
||||||
|
this.setCurShortCutObj({ data });
|
||||||
|
},
|
||||||
|
handleOnNameChange(val, data) {
|
||||||
|
this.modifingId = data.id;
|
||||||
|
},
|
||||||
|
handleOnHide() {
|
||||||
|
if (this.modifingId) {
|
||||||
|
const tarObj = this.dataList.find((obj) => obj.id === this.modifingId);
|
||||||
|
editShortCut({
|
||||||
|
id: this.modifingId,
|
||||||
|
name: tarObj.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
translateType(type) {
|
||||||
|
return type.map((t) => {
|
||||||
|
if (t === "0") {
|
||||||
|
return "整天";
|
||||||
|
} else if (t === "1") {
|
||||||
|
return "早餐";
|
||||||
|
} else if (t === "2") {
|
||||||
|
return "早加餐";
|
||||||
|
} else if (t === "3") {
|
||||||
|
return "午餐";
|
||||||
|
} else if (t === "4") {
|
||||||
|
return "午加餐";
|
||||||
|
} else if (t === "5") {
|
||||||
|
return "晚餐";
|
||||||
|
} else if (t === "6") {
|
||||||
|
return "晚加餐";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
...mapMutations(["setCurShortCutObj"]),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.short_cut_com_wrapper {
|
||||||
|
.header {
|
||||||
|
text-align: right;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -27,7 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="快捷列表" name="3">
|
<el-tab-pane label="快捷列表" name="3">
|
||||||
|
<ShortCutCom />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
@ -40,6 +40,7 @@ import HealthyView from "@/components/HealthyView";
|
|||||||
import BodySignView from "@/components/BodySignView";
|
import BodySignView from "@/components/BodySignView";
|
||||||
import WeaklyAnalyzeCom from "./WeaklyAnalyzeCom";
|
import WeaklyAnalyzeCom from "./WeaklyAnalyzeCom";
|
||||||
import DailyAnalyzeCom from "./DailyAnalyzeCom";
|
import DailyAnalyzeCom from "./DailyAnalyzeCom";
|
||||||
|
import ShortCutCom from "./ShortCutCom";
|
||||||
export default {
|
export default {
|
||||||
name: "InfoView",
|
name: "InfoView",
|
||||||
data() {
|
data() {
|
||||||
@ -52,6 +53,7 @@ export default {
|
|||||||
TemplateInfoView,
|
TemplateInfoView,
|
||||||
WeaklyAnalyzeCom,
|
WeaklyAnalyzeCom,
|
||||||
DailyAnalyzeCom,
|
DailyAnalyzeCom,
|
||||||
|
ShortCutCom,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
max() {
|
max() {
|
||||||
|
@ -21,10 +21,10 @@ export default {
|
|||||||
editing: false,
|
editing: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: ["value"],
|
props: ["value", "disabled"],
|
||||||
methods: {
|
methods: {
|
||||||
handleOnClick(e) {
|
handleOnClick(e) {
|
||||||
if (!this.editing) {
|
if (!this.editing && !this.disabled) {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs["inputRef"].focus();
|
this.$refs["inputRef"].focus();
|
||||||
|
@ -40,7 +40,7 @@ import { createNamespacedHelpers } from "vuex";
|
|||||||
const { mapState, mapGetters } = createNamespacedHelpers("recipes");
|
const { mapState, mapGetters } = createNamespacedHelpers("recipes");
|
||||||
export default {
|
export default {
|
||||||
name: "EditableUnit",
|
name: "EditableUnit",
|
||||||
props: ["weight", "unit"],
|
props: ["weight", "unit", "disabled"],
|
||||||
mounted() {
|
mounted() {
|
||||||
window.addEventListener("click", this.handleOnWindowClick);
|
window.addEventListener("click", this.handleOnWindowClick);
|
||||||
},
|
},
|
||||||
@ -56,7 +56,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleOnClick(e) {
|
handleOnClick(e) {
|
||||||
if (!this.editing) {
|
if (!this.editing && !this.disabled) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
}, 0);
|
}, 0);
|
||||||
|
@ -9,33 +9,80 @@
|
|||||||
size="mini"
|
size="mini"
|
||||||
header-row-class-name="recipes_header"
|
header-row-class-name="recipes_header"
|
||||||
:cell-class-name="cellClassName"
|
:cell-class-name="cellClassName"
|
||||||
:style="`outline: ${currentDay === num ? '1px solid #d53950' : 'none'}`"
|
:style="`outline: ${
|
||||||
|
currentDay === num && !preview ? '1px solid #d53950' : 'none'
|
||||||
|
}`"
|
||||||
>
|
>
|
||||||
<el-table-column prop="type" :width="80" align="center">
|
<el-table-column prop="type" :width="80" align="center">
|
||||||
<template slot="header">
|
<template slot="header">
|
||||||
<div class="pointer_style" @click="handleOnResetCurrentDay">
|
|
||||||
{{ `第${numDay}天` }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-popover
|
<el-popover
|
||||||
placement="top"
|
placement="right"
|
||||||
|
:open-delay="200"
|
||||||
trigger="hover"
|
trigger="hover"
|
||||||
:title="typeFormatter(scope.row)"
|
:title="`第${numDay}天`"
|
||||||
|
:disabled="preview"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleOnMenuTypeClick(scope.row)"
|
icon="el-icon-position"
|
||||||
>添加
|
@click="handleOnMenuCopyClick"
|
||||||
|
>
|
||||||
|
添加快捷
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handleOnPaste(scope.row.type)"
|
icon="el-icon-refresh"
|
||||||
v-if="canCopyMenuTypes.includes(scope.row.type)"
|
v-if="shouldPasteShow('0')"
|
||||||
>粘贴</el-button
|
@click="handleOnMenuPasteClick"
|
||||||
|
>快捷替换</el-button
|
||||||
|
>
|
||||||
|
<div v-else-if="curShortCutObj.type" style="margin-top: 8px">
|
||||||
|
<el-button
|
||||||
|
icon="el-icon-right"
|
||||||
|
size="mini"
|
||||||
|
type="primary"
|
||||||
|
v-for="item in curShortCutObj.type"
|
||||||
|
:key="item"
|
||||||
|
@click="handleOnShortCutMenuAdd(item)"
|
||||||
|
>{{ menuTypeDict[item] }}</el-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="pointer_style"
|
||||||
|
@click="handleOnResetCurrentDay"
|
||||||
|
slot="reference"
|
||||||
|
>
|
||||||
|
{{ `第${numDay}天` }}
|
||||||
|
</div>
|
||||||
|
</el-popover>
|
||||||
|
</template>
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-popover
|
||||||
|
placement="top"
|
||||||
|
trigger="hover"
|
||||||
|
:open-delay="200"
|
||||||
|
:title="typeFormatter(scope.row)"
|
||||||
|
:disabled="preview"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
@click="handleOnMenuTypeClick(scope.row)"
|
||||||
|
>添加菜品
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-position"
|
||||||
|
@click="handleOnShortCutMenuAdd(scope.row.type)"
|
||||||
|
v-if="shouldPasteShow(scope.row.type)"
|
||||||
|
>快捷添加</el-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -52,7 +99,13 @@
|
|||||||
<div class="pointer_style" @click="handleOnAdd">菜品</div>
|
<div class="pointer_style" @click="handleOnAdd">菜品</div>
|
||||||
</template>
|
</template>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-popover placement="right" trigger="hover" :title="scope.row.name">
|
<el-popover
|
||||||
|
placement="right"
|
||||||
|
:open-delay="200"
|
||||||
|
trigger="hover"
|
||||||
|
:title="scope.row.name"
|
||||||
|
:disabled="preview"
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<div style="margin-bottom: 8px">
|
<div style="margin-bottom: 8px">
|
||||||
<el-button
|
<el-button
|
||||||
@ -62,7 +115,7 @@
|
|||||||
class="fun_button"
|
class="fun_button"
|
||||||
@click="handleOnReplace(scope.row)"
|
@click="handleOnReplace(scope.row)"
|
||||||
>
|
>
|
||||||
替换
|
替换菜品
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
@ -71,18 +124,18 @@
|
|||||||
class="fun_button"
|
class="fun_button"
|
||||||
@click="handleOnDelete(scope.row)"
|
@click="handleOnDelete(scope.row)"
|
||||||
>
|
>
|
||||||
删除
|
删除菜品
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div style="margin-bottom: 8px">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="mini"
|
size="mini"
|
||||||
icon="el-icon-document-copy"
|
icon="el-icon-position"
|
||||||
class="fun_button"
|
class="fun_button"
|
||||||
@click="handleOnCopy(scope.row)"
|
@click="handleOnCopy(scope.row)"
|
||||||
>
|
>
|
||||||
复制
|
添加快捷
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@ -94,6 +147,18 @@
|
|||||||
修改餐类
|
修改餐类
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
size="mini"
|
||||||
|
icon="el-icon-refresh"
|
||||||
|
class="fun_button"
|
||||||
|
v-if="shouldPasteShow(scope.row.type)"
|
||||||
|
@click="handleOnShortCutReplace(scope.row)"
|
||||||
|
>
|
||||||
|
快捷替换
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pointer_style" slot="reference">
|
<div class="pointer_style" slot="reference">
|
||||||
{{ scope.row.name }}
|
{{ scope.row.name }}
|
||||||
@ -115,8 +180,10 @@
|
|||||||
<el-popover
|
<el-popover
|
||||||
v-else
|
v-else
|
||||||
placement="right"
|
placement="right"
|
||||||
|
:open-delay="200"
|
||||||
trigger="hover"
|
trigger="hover"
|
||||||
:title="scope.row.igdName"
|
:title="scope.row.igdName"
|
||||||
|
:disabled="preview"
|
||||||
>
|
>
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
@ -137,6 +204,7 @@
|
|||||||
<EditableUnit
|
<EditableUnit
|
||||||
:weight="scope.row.cusWeight"
|
:weight="scope.row.cusWeight"
|
||||||
:unit="scope.row.cusUnit"
|
:unit="scope.row.cusUnit"
|
||||||
|
:disabled="preview"
|
||||||
@onChange="(val) => handleOnCustomUnitChange(scope.row, val)"
|
@onChange="(val) => handleOnCustomUnitChange(scope.row, val)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@ -145,6 +213,7 @@
|
|||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<EditableText
|
<EditableText
|
||||||
:value="scope.row.weight"
|
:value="scope.row.weight"
|
||||||
|
:disabled="preview"
|
||||||
@onChange="(val) => handleOnWeightChange(scope.row, val)"
|
@onChange="(val) => handleOnWeightChange(scope.row, val)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@ -154,6 +223,7 @@
|
|||||||
prop="proteinRatio"
|
prop="proteinRatio"
|
||||||
:width="60"
|
:width="60"
|
||||||
align="center"
|
align="center"
|
||||||
|
v-if="!preview"
|
||||||
>
|
>
|
||||||
<template slot="header">
|
<template slot="header">
|
||||||
<div class="pointer_style">
|
<div class="pointer_style">
|
||||||
@ -167,6 +237,7 @@
|
|||||||
prop="fatRatio"
|
prop="fatRatio"
|
||||||
:width="60"
|
:width="60"
|
||||||
align="center"
|
align="center"
|
||||||
|
v-if="!preview"
|
||||||
>
|
>
|
||||||
<template slot="header">
|
<template slot="header">
|
||||||
<div class="pointer_style">
|
<div class="pointer_style">
|
||||||
@ -180,6 +251,7 @@
|
|||||||
prop="carbonRatio"
|
prop="carbonRatio"
|
||||||
:width="60"
|
:width="60"
|
||||||
align="center"
|
align="center"
|
||||||
|
v-if="!preview"
|
||||||
>
|
>
|
||||||
<template slot="header">
|
<template slot="header">
|
||||||
<div class="pointer_style">
|
<div class="pointer_style">
|
||||||
@ -194,6 +266,7 @@
|
|||||||
:width="60"
|
:width="60"
|
||||||
align="center"
|
align="center"
|
||||||
:formatter="nutriFormatter"
|
:formatter="nutriFormatter"
|
||||||
|
v-if="!preview"
|
||||||
>
|
>
|
||||||
<template slot="header">
|
<template slot="header">
|
||||||
<div class="pointer_style">
|
<div class="pointer_style">
|
||||||
@ -208,6 +281,7 @@
|
|||||||
:width="60"
|
:width="60"
|
||||||
align="center"
|
align="center"
|
||||||
:formatter="nutriFormatter"
|
:formatter="nutriFormatter"
|
||||||
|
v-if="!preview"
|
||||||
>
|
>
|
||||||
<template slot="header">
|
<template slot="header">
|
||||||
<div class="pointer_style">
|
<div class="pointer_style">
|
||||||
@ -222,6 +296,7 @@
|
|||||||
:width="60"
|
:width="60"
|
||||||
align="center"
|
align="center"
|
||||||
:formatter="nutriFormatter"
|
:formatter="nutriFormatter"
|
||||||
|
v-if="!preview"
|
||||||
>
|
>
|
||||||
<template slot="header">
|
<template slot="header">
|
||||||
<div class="pointer_style">
|
<div class="pointer_style">
|
||||||
@ -230,8 +305,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="做法" prop="methods" />
|
<el-table-column label="做法" prop="methods" v-if="!preview" />
|
||||||
<el-table-column label="备注" prop="remark">
|
<el-table-column label="备注" prop="remark" v-if="!preview">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<div
|
<div
|
||||||
v-if="!scope.row.remark"
|
v-if="!scope.row.remark"
|
||||||
@ -276,13 +351,15 @@ import DishesSettingDialog from "./DishesSettingDialog";
|
|||||||
import VueScrollTo from "vue-scrollto";
|
import VueScrollTo from "vue-scrollto";
|
||||||
import RemarkDialog from "./RemarkDialog";
|
import RemarkDialog from "./RemarkDialog";
|
||||||
import { processMenuData } from "./utils";
|
import { processMenuData } from "./utils";
|
||||||
|
import { addShortCut } from "@/utils/shortCutUtils";
|
||||||
|
import { messageTypes } from "@/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "RecipesCom",
|
name: "RecipesCom",
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: [],
|
default: {},
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
@ -297,6 +374,10 @@ export default {
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
preview: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
EditableText,
|
EditableText,
|
||||||
@ -309,7 +390,16 @@ export default {
|
|||||||
// console.log(this.data);
|
// console.log(this.data);
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {};
|
return {
|
||||||
|
menuTypeDict: {
|
||||||
|
1: "早餐",
|
||||||
|
2: "早加餐",
|
||||||
|
3: "午餐",
|
||||||
|
4: "午加餐",
|
||||||
|
5: "晚餐",
|
||||||
|
6: "晚加餐",
|
||||||
|
},
|
||||||
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
notIds() {
|
notIds() {
|
||||||
@ -327,15 +417,70 @@ export default {
|
|||||||
...mapGetters(["typeDict"]),
|
...mapGetters(["typeDict"]),
|
||||||
...mapState([
|
...mapState([
|
||||||
"currentDay",
|
"currentDay",
|
||||||
"copyData",
|
// "copyData",
|
||||||
"fontSize",
|
"fontSize",
|
||||||
"canCopyMenuTypes",
|
// "canCopyMenuTypes",
|
||||||
"recipesId",
|
"recipesId",
|
||||||
"notRecIgds",
|
"notRecIgds",
|
||||||
"avoidFoodIds",
|
"avoidFoodIds",
|
||||||
|
"curShortCutObj",
|
||||||
|
"healthyData",
|
||||||
|
"templateInfo",
|
||||||
]),
|
]),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleOnShortCutReplace(data) {
|
||||||
|
this.updateDishes({
|
||||||
|
num: this.num,
|
||||||
|
data: {
|
||||||
|
...this.curShortCutObj.data,
|
||||||
|
type: data.type,
|
||||||
|
id: data.id,
|
||||||
|
},
|
||||||
|
actionType: "replace",
|
||||||
|
}).catch((err) => {
|
||||||
|
this.$message.error(err);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleOnShortCutMenuAdd(type) {
|
||||||
|
const data = {
|
||||||
|
...JSON.parse(JSON.stringify(this.curShortCutObj.data)),
|
||||||
|
type,
|
||||||
|
};
|
||||||
|
if (!this.recipesId) {
|
||||||
|
// 未生成食谱时拷贝
|
||||||
|
data.id = new Date().getTime();
|
||||||
|
}
|
||||||
|
this.addDishes({
|
||||||
|
num: this.num,
|
||||||
|
data,
|
||||||
|
}).catch((err) => {
|
||||||
|
this.$message.error(err);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleOnMenuPasteClick() {
|
||||||
|
if (!this.curShortCutObj || !this.curShortCutObj.data.dishes) {
|
||||||
|
this.$message.error("快捷对象错误");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { id } = this.data;
|
||||||
|
this.replaceMenu({
|
||||||
|
num: this.num,
|
||||||
|
data: {
|
||||||
|
numDay: this.numDay,
|
||||||
|
id,
|
||||||
|
dishes: this.curShortCutObj.data.dishes.map((obj) => ({
|
||||||
|
...obj,
|
||||||
|
id: id + obj.id,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
shouldPasteShow(type) {
|
||||||
|
return (
|
||||||
|
this.curShortCutObj.type && this.curShortCutObj.type.includes(type)
|
||||||
|
);
|
||||||
|
},
|
||||||
cellClassName({ row, column, rowIndex, columnIndex }) {
|
cellClassName({ row, column, rowIndex, columnIndex }) {
|
||||||
// console.log({ row, column, rowIndex, columnIndex });
|
// console.log({ row, column, rowIndex, columnIndex });
|
||||||
if (!columnIndex) {
|
if (!columnIndex) {
|
||||||
@ -349,6 +494,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleParentClick(e) {
|
handleParentClick(e) {
|
||||||
|
if (this.preview) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 校验某天
|
// 校验某天
|
||||||
this.setCurrentDay({ currentDay: this.num });
|
this.setCurrentDay({ currentDay: this.num });
|
||||||
},
|
},
|
||||||
@ -370,6 +518,9 @@ export default {
|
|||||||
return ((row.weight / 100) * row[col.property]).toFixed(1);
|
return ((row.weight / 100) * row[col.property]).toFixed(1);
|
||||||
},
|
},
|
||||||
handleOnResetCurrentDay(e) {
|
handleOnResetCurrentDay(e) {
|
||||||
|
if (this.preview) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// 取消高亮
|
// 取消高亮
|
||||||
this.resetCurrentDay({ currentDay: this.num });
|
this.resetCurrentDay({ currentDay: this.num });
|
||||||
@ -379,6 +530,9 @@ export default {
|
|||||||
},
|
},
|
||||||
handleOnAdd() {
|
handleOnAdd() {
|
||||||
// console.log(this.num);
|
// console.log(this.num);
|
||||||
|
if (this.preview) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.$refs.drawerRef.showDrawer({});
|
this.$refs.drawerRef.showDrawer({});
|
||||||
},
|
},
|
||||||
handleOnReplace(data) {
|
handleOnReplace(data) {
|
||||||
@ -398,25 +552,25 @@ export default {
|
|||||||
this.$message.error(err);
|
this.$message.error(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleOnPaste(type) {
|
// handleOnPaste(type) {
|
||||||
// console.log(this.copyData);
|
// // console.log(this.copyData);
|
||||||
if (this.copyData) {
|
// if (this.copyData) {
|
||||||
const data = {
|
// const data = {
|
||||||
...JSON.parse(JSON.stringify(this.copyData)),
|
// ...JSON.parse(JSON.stringify(this.copyData)),
|
||||||
type,
|
// type,
|
||||||
};
|
// };
|
||||||
if (!this.recipesId) {
|
// if (!this.recipesId) {
|
||||||
// 未生成食谱时拷贝
|
// // 未生成食谱时拷贝
|
||||||
data.id = new Date().getTime();
|
// data.id = new Date().getTime();
|
||||||
}
|
// }
|
||||||
this.addDishes({
|
// this.addDishes({
|
||||||
num: this.num,
|
// num: this.num,
|
||||||
data,
|
// data,
|
||||||
}).catch((err) => {
|
// }).catch((err) => {
|
||||||
this.$message.error(err);
|
// this.$message.error(err);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
handleOnWeightChange(data, weight) {
|
handleOnWeightChange(data, weight) {
|
||||||
// console.log({ data, weight });
|
// console.log({ data, weight });
|
||||||
this.updateDishes({
|
this.updateDishes({
|
||||||
@ -507,12 +661,38 @@ export default {
|
|||||||
this.$message.error(err);
|
this.$message.error(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
handleOnMenuCopyClick() {
|
||||||
|
// console.log({
|
||||||
|
// numDay: this.numDay,
|
||||||
|
// data: this.data,
|
||||||
|
// healthyData: this.healthyData,
|
||||||
|
// templateInfo: this.templateInfo,
|
||||||
|
// });
|
||||||
|
const name = `${
|
||||||
|
this.healthyData ? this.healthyData.name : this.templateInfo.name
|
||||||
|
}-第${this.numDay}天`;
|
||||||
|
addShortCut({
|
||||||
|
name,
|
||||||
|
id: new Date().getTime(),
|
||||||
|
type: ["0"],
|
||||||
|
data: this.data,
|
||||||
|
}).then(() => {
|
||||||
|
this.$message.success("添加成功");
|
||||||
|
window.postMessage(
|
||||||
|
{
|
||||||
|
type: messageTypes.UPDATE_SHORTCUT,
|
||||||
|
},
|
||||||
|
"*"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
...mapActions([
|
...mapActions([
|
||||||
"updateDishes",
|
"updateDishes",
|
||||||
"addDishes",
|
"addDishes",
|
||||||
"deleteDishes",
|
"deleteDishes",
|
||||||
"replaceDishes",
|
"replaceDishes",
|
||||||
"setCopyData",
|
"setCopyData",
|
||||||
|
"replaceMenu",
|
||||||
]),
|
]),
|
||||||
...mapMutations(["setCurrentDay", "resetCurrentDay"]),
|
...mapMutations(["setCurrentDay", "resetCurrentDay"]),
|
||||||
},
|
},
|
||||||
|
@ -200,6 +200,7 @@ export default {
|
|||||||
{ dictValue: 0, dictLabel: "未制作" },
|
{ dictValue: 0, dictLabel: "未制作" },
|
||||||
{ dictValue: 1, dictLabel: "未审核" },
|
{ dictValue: 1, dictLabel: "未审核" },
|
||||||
{ dictValue: 2, dictLabel: "已审核" },
|
{ dictValue: 2, dictLabel: "已审核" },
|
||||||
|
{ dictValue: 3, dictLabel: "制作中" },
|
||||||
],
|
],
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user