From a802103243c8a99301efdc083338251915e28b93 Mon Sep 17 00:00:00 2001 From: guoxin Date: Wed, 15 Nov 2023 02:54:35 +0800 Subject: [PATCH] =?UTF-8?q?fix():=E4=BF=AE=E6=94=B9=E8=AE=A1=E8=B4=B9?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessMgm/ChargeRules/EditModal.jsx | 406 +++++++++++++++++---- .../BusinessMgm/ChargeRules/FormModal.jsx | 164 ++++++--- .../InRoadMgm/Stuff/CategroyConf/loadable.jsx | 9 +- src/pages/InRoadMgm/Stuff/StuffMgm/loadable.jsx | 69 +++- .../CallbackSuggestion/loadable.jsx | 3 +- src/services/search.js | 9 + 6 files changed, 502 insertions(+), 158 deletions(-) diff --git a/src/pages/InRoadMgm/BusinessMgm/ChargeRules/EditModal.jsx b/src/pages/InRoadMgm/BusinessMgm/ChargeRules/EditModal.jsx index b753d77..d4c2097 100644 --- a/src/pages/InRoadMgm/BusinessMgm/ChargeRules/EditModal.jsx +++ b/src/pages/InRoadMgm/BusinessMgm/ChargeRules/EditModal.jsx @@ -1,9 +1,10 @@ import React, { useState, useRef, useEffect } from "react"; import { Select, Input, Button, Modal, Checkbox, DatePicker, Space, TimePicker, Form, Popover, message } from 'antd' -import { MinusCircleOutlined, PlusCircleOutlined } from "@ant-design/icons"; +import { MinusCircleOutlined, PlusCircleOutlined, QuestionCircleOutlined } from "@ant-design/icons"; import "./index.scss"; import ajax from '@/services' import moment from 'moment'; +import { set } from "js-cookie"; const { TextArea } = Input; const format = 'HH:mm'; @@ -79,6 +80,7 @@ const FormModal = (props) => { const [open, setOpen] = useState(false); const [previousValueEnd, setPreviousValueEnd] = useState(null); const [formData, setFormData] = useState(defaultData) + const [startTime, setStartTime] = useState([]); const [endTime, setEndTime] = useState([]); const [previousValueStart, setPreviousValueStart] = useState(null); const [getNewCar, setGetNewCar] = useState(false) @@ -211,12 +213,15 @@ const FormModal = (props) => { // 表单提交 const onFinish = (data) => { - let newData = handelDate(data, 1) - ajax.deleteChangeRules(newData).then(res => { - if (res.status === 20000) { - editVisible = false - } - }) + //校验数据 + if(handleFormValidation(data,0)&&handleFormValidation(data,1)){ + let newData = handelDate(data, 1) + ajax.deleteChangeRules(newData).then(res => { + if (res.status === 20000) { + editVisible = false + } + }) + } }; useEffect(() => { @@ -225,17 +230,11 @@ const FormModal = (props) => { if (JSON.stringify(yisaData) != "{}") { newObj = handelDate(yisaData, 2) } - // console.log("1111",newObj); + newObj.rules = newObj?.source?.rules - //生成初始组件 - if(newObj.rules!=null){ - for (let i = 0; i < newObj.rules[0].details.length; i++) { - for (let z = 0; z < newObj.rules[0].details[i].items.length; z++) { - handleOptionsProcessing(i, z, options); - } - } - } delete newObj.source + //生成初始组件 + init(newObj); form.setFieldsValue(newObj); }, [yisaData]); @@ -313,18 +312,78 @@ const FormModal = (props) => { key: 0 } ] + + //首次生成初始组件 + const init = (newObj) => { + console.log("11111111111newObj",newObj) + if(newObj.rules==null){ + return; + } + if(newObj.rules[0].holiday.length>0){ + setGetValueData(2) + }else{ + newObj.rules[0].holiday = defaultData.rules[0].holiday; + } + if(newObj.rules[0].details.length>0){ + for (let i = 0; i < newObj.rules[0].details.length; i++) { + for (let z = 0; z < newObj.rules[0].details[i].items.length; z++) { + handleOptionsProcessing(i, z, options,0); + } + } + } + if(newObj.rules[0].holiday.length>0){ + for (let i = 0; i < newObj.rules[0].holiday.length; i++) { + for (let z = 0; z < newObj.rules[0].holiday[i].items.length; z++) { + handleOptionsProcessing(i, z, options,1); + } + } + } + } + //提交表单校验 + const handleFormValidation = (data,type) => { + const validationData = type == 0 ? data.rules[0].details : data.rules[0].holiday + let flag = false; + let totalMinutes = 0; // 初始化总分钟数为0 + validationData.forEach((isData) => { + if (isData.end == null || isData.start == null) { + message.error("时间字段不能为空"); + flag = false; + return; + } + const endTime = moment(isData.end, "HH:mm"); + const startTime = moment(isData.start, "HH:mm"); + const duration = Math.ceil(endTime.diff(startTime, "seconds") / 60); + console.log("endTime:"+ endTime + "-- startTime:" + startTime+"-- duration:"+duration); // 输出每个 details 中总时间的数组 + totalMinutes += duration; // 将时间差累加到总分钟数中 + }); + const totalHours = Math.floor(totalMinutes / 60); + const remainingMinutes = totalMinutes % 60; + console.log("当前区间时间总和", totalHours + ":" + remainingMinutes); // 输出每个 details 中总时间的数组 + if (totalHours === 23 && remainingMinutes === 59) { + flag = true; + } else { + message.error("时间区间总和需要为23:59,请完善区间"); + } + //判断holiday不是自定义 + if(getValueData !=2 ){ + data.rules[0].holiday = []; + } + return flag; + }; //初始区间数据 const [selectOptions, setSelectOptions] = useState({ "00": options }); + const [selectHolidayOptions, setSelectHolidayOptions] = useState({ "00": options }); //添加工作日计费&&非工作计费 const handleAddRulesClick = (type) => { const currentFormValues = form.getFieldsValue(); const data = type == 0 ? currentFormValues.rules[0].details : currentFormValues.rules[0].holiday //校验规则 - if (!handleValidation(data)) { + if (!handleValidation(data,type)) { return; } //同步更改模板开始时间为上一条的结束时间 - type == 0 ? newDetails.start = moment(data[data.length - 1].end) : newHoliday.start = moment(data[data.length - 1].end) + newDetails.start = moment(data[data.length - 1].end); + newHoliday.start = moment(data[data.length - 1].end); //将新的规则数据合并到当前表单的值中 const updatedDetailsOrHoliday = [...data, type == 0 ? newDetails : newHoliday]; form.setFieldsValue({ @@ -332,85 +391,105 @@ const FormModal = (props) => { rules: [type == 0 ? { ...currentFormValues.rules[0], details: updatedDetailsOrHoliday } : { ...currentFormValues.rules[0], holiday: updatedDetailsOrHoliday }] }); //区间类型-下拉数据更新 - handleOptionsProcessing(data.length, 0, options); + handleOptionsProcessing(data.length, 0, options,type); console.log("当前表单", currentFormValues); } //添加工作日计费&&非工作计费-校验 - const handleValidation = (data) => { + const handleValidation = (data,type) => { let flag = true; //校验一,计算所有时间区间总和是否大于24小时,将时间戳转为小时,取整 - const totalTimes = data.reduce((total, isData) => { + let totalMinutes = 0; // 初始化总分钟数为0 + data.forEach((isData) => { if (isData.end == null || isData.start == null) { - message.error('时间字段不能为空'); + message.error("时间字段不能为空"); flag = false; + return; } - if (isData.end) { - const endTime = moment(isData.end); // 将 end 转换成 Moment 对象 - const startTime = moment(isData.start); // 将 start 转换成 Moment 对象 - const duration = moment.duration(endTime.diff(startTime)); // 计算时间差 - return total + duration.asMilliseconds(); // 将时间差累加到总时间中 - } else { - return total; - } - }, 0); - const totalHours = Math.ceil(moment.duration(totalTimes).asHours()); - console.log("当前区间时间总和", totalHours); // 输出每个 details 中总时间的数组 - if (totalHours > 24) { - message.error('当前时间区间大于24小时,不能再添加'); + const endTime = moment(isData.end, "HH:mm"); + const startTime = moment(isData.start, "HH:mm"); + const duration = Math.ceil(endTime.diff(startTime, "seconds") / 60); + console.log("endTime:"+ endTime + "-- startTime:" + startTime+"-- duration:"+duration); // 输出每个 details 中总时间的数组 + totalMinutes += duration; // 将时间差累加到总分钟数中 + }); + const totalHours = Math.floor(totalMinutes / 60); + const remainingMinutes = totalMinutes % 60; + console.log("当前区间时间总和", totalHours + ":" + remainingMinutes); // 输出每个 details 中总时间的数组 + if (totalHours > 23 && totalMinutes > 59) { + message.error('时间区间总和需要为23:59,请完善区间'); flag = false; - } + } return flag; } //添加区间 - const handleAddItemsClick = (i, z) => { + const handleAddItemsClick = (i, z,type) => { const currentFormValues = form.getFieldsValue(); + const data = type == 0 ? currentFormValues.rules[0].details : currentFormValues.rules[0].holiday + //如果第一个为基础时段则下一个改为周期计划 + newItems.type = data[i].items[0].type==0?2:0 //将新的区间数据合并到当前表单的值中 const updatedItems = [ - ...currentFormValues.rules[0].details.slice(0, i), + ...data.slice(0, i), { - ...currentFormValues.rules[0].details[i], - items: [...currentFormValues.rules[0].details[i].items, newItems] + ...data[i], + items: [...data[i].items, newItems] }, - ...currentFormValues.rules[0].details.slice(i + 1) + ...data.slice(i + 1) ]; - form.setFieldsValue({ - ...currentFormValues, - rules: [{ - ...currentFormValues.rules[0], - details: updatedItems - }] - }); - + if(type==0){ + form.setFieldsValue({ + ...currentFormValues, + rules: [{ + ...currentFormValues.rules[0], + details:updatedItems, + }] + }); + }else{ + form.setFieldsValue({ + ...currentFormValues, + rules: [{ + ...currentFormValues.rules[0], + holiday:updatedItems, + }] + }); + } //校验规则 - if (!handleItemsValidation(i, z)) { + if (!handleItemsValidation(i, z,data[i].items[0].type,type)) { return; } } //添加区间-校验 - const handleItemsValidation = (i, z, value) => { + const handleItemsValidation = (i, z, value,type) => { const currentFormValues = form.getFieldsValue(); // 校验1.当选择基础时段时,可以选择其他两项 // 校验2.当选择周期计划时,不能选择其他项 // 校验3.当选择按次收费金额,不能选择其他项 // 校验4.增加时段最高收费金额,当选择按次计费时时段最高收费金额输入框影藏 const data = value == 1 || value == 2 ? options.filter(op => op.value == value) : options; - handleOptionsProcessing(i, z, data)//统一区间类型下拉数据更新 + handleOptionsProcessing(i, z, data,type)//统一区间类型下拉数据更新 console.log("表单数据", currentFormValues); return true; } //区间类型-下拉数据更新 - const handleOptionsProcessing = (i, z, data) => { + const handleOptionsProcessing = (i, z, data,type) => { const key = i + '' + z; console.log(key, data); - setSelectOptions(prevOptions => ({ - ...prevOptions, - [key]: data - })); + if(type==0){ + setSelectOptions(prevOptions => ({ + ...prevOptions, + [key]: data + })); + }else{ + setSelectHolidayOptions(prevOptions => ({ + ...prevOptions, + [key]: data + })); + } + }; //区间类型-下拉数据查询-通过下标查询指定组件value - const getOptionsValueByIndex = (i, z) => { + const getOptionsValueByIndex = (i, z,type) => { const key = i + '' + z; - const value = selectOptions[key][z].value; + const value = type==0?selectOptions[key][z].value:selectHolidayOptions[key][z].value; console.log("getOptionsValueByIndex", value); return value; }; @@ -785,10 +864,10 @@ const FormModal = (props) => { className="btm-box" > { - fields.length < 2 && getOptionsValueByIndex(i, z) != 1 && getOptionsValueByIndex(i, z) != 2 ? + fields.length < 2 && getOptionsValueByIndex(i, z,0) != 1 && getOptionsValueByIndex(i, z,0) != 2 ? - handleAddItemsClick(i, fields.length) + handleAddItemsClick(i, fields.length,0) } /> : fields.length > 1 ? @@ -852,12 +931,11 @@ const FormModal = (props) => { {(fields, { add, remove }) => ( <> - {fields.map(({ key, name, ...restField }, j) => { - // console.log(fields); + {fields.map(({ key, name, ...restField }, i) => { return ( -
+
- + @@ -867,22 +945,26 @@ const FormModal = (props) => { {...restField} name={[name, "start"]} label="时段" + className="yisa-label" > - + - to + - + + - { + { !i ? { handleAddRulesClick(1); }} /> : @@ -890,13 +972,13 @@ const FormModal = (props) => { }
+ {(fields, { add, remove }) => ( <> {fields.map(({ key, name, ...restField }, z) => { - // console.log(fields); return ( -
+
{ > { setGetValue2(v) }} + style={{ width: 100, marginLeft: 10 }} + options={[ + { + value: 0, + label: '基础时段', + }, + { + value: 2, + label: '周期计划', + }, + { + value: 1, + label: '按次收费', + }, + ]} + /> + + { + getValue2 == 1 ? +
+ + + + +
+ : +
+ + + + + + + + + + + + + +
+ } + + { + getValue2 === 2 ? + + add({ + "type": 0, + "segment": 0, + "threshold": 0, + "period": 0, + "unit": 0 + }) + } + /> : fields.length > 1 ? + { + remove(name); + }} + /> + : null + } + +
+
+ ); + })} + + )} + +
+ ); + })} + + )} +
*/}
diff --git a/src/pages/InRoadMgm/BusinessMgm/ChargeRules/FormModal.jsx b/src/pages/InRoadMgm/BusinessMgm/ChargeRules/FormModal.jsx index a2e922b..b638e23 100644 --- a/src/pages/InRoadMgm/BusinessMgm/ChargeRules/FormModal.jsx +++ b/src/pages/InRoadMgm/BusinessMgm/ChargeRules/FormModal.jsx @@ -236,8 +236,9 @@ const FormModal = (props) => { // 表单提交 const onFinish = (data) => { //校验数据 - if(handleValidation(data.rules[0].details)&&handleValidation(data.rules[0].holiday)){ - ajax.addChangeRules(data).then(res => { + if(handleFormValidation(data,0)&&handleFormValidation(data,1)){ + let newData = handelDate(data, 1) + ajax.addChangeRules(newData).then(res => { if (res.status === 20000) { setGetAddVisible(false) } @@ -271,8 +272,7 @@ const FormModal = (props) => { } else { setStartTime([]) } - - }; + } const handleChangeEndTime = (time, timeString) => { setOpen(false); @@ -287,10 +287,6 @@ const FormModal = (props) => { setEndTime([]) } }; - - - - //区间模板 const newItems = { "type": 0, @@ -331,8 +327,40 @@ const FormModal = (props) => { key: 0 } ] + //提交表单校验 + const handleFormValidation = (data,type) => { + const validationData = type == 0 ? data.rules[0].details : data.rules[0].holiday + let flag = false; + let totalMinutes = 0; // 初始化总分钟数为0 + validationData.forEach((isData) => { + if (isData.end == null || isData.start == null) { + message.error("时间字段不能为空"); + flag = false; + return; + } + const endTime = moment(isData.end, "HH:mm"); + const startTime = moment(isData.start, "HH:mm"); + const duration = Math.ceil(endTime.diff(startTime, "seconds") / 60); + console.log("endTime:"+ endTime + "-- startTime:" + startTime+"-- duration:"+duration); // 输出每个 details 中总时间的数组 + totalMinutes += duration; // 将时间差累加到总分钟数中 + }); + const totalHours = Math.floor(totalMinutes / 60); + const remainingMinutes = totalMinutes % 60; + console.log("当前区间时间总和", totalHours + ":" + remainingMinutes); // 输出每个 details 中总时间的数组 + if (totalHours === 23 && remainingMinutes === 59) { + flag = true; + } else { + message.error("时间区间总和需要为23:59,请完善区间"); + } + //判断holiday不是自定义 + if(getValueData !=2 ){ + data.rules[0].holiday = []; + } + return flag; + }; //初始区间数据 const [selectOptions, setSelectOptions] = useState({ "00": options }); + const [selectHolidayOptions, setSelectHolidayOptions] = useState({ "00": options }); //添加工作日计费&&非工作计费 const handleAddRulesClick = (type) => { const currentFormValues = form.getFieldsValue(); @@ -342,7 +370,8 @@ const FormModal = (props) => { return; } //同步更改模板开始时间为上一条的结束时间 - type == 0 ? newDetails.start = moment(data[data.length - 1].end) : newHoliday.start = moment(data[data.length - 1].end) + newDetails.start = moment(data[data.length - 1].end); + newHoliday.start = moment(data[data.length - 1].end); //将新的规则数据合并到当前表单的值中 const updatedDetailsOrHoliday = [...data, type == 0 ? newDetails : newHoliday]; form.setFieldsValue({ @@ -350,86 +379,105 @@ const FormModal = (props) => { rules: [type == 0 ? { ...currentFormValues.rules[0], details: updatedDetailsOrHoliday } : { ...currentFormValues.rules[0], holiday: updatedDetailsOrHoliday }] }); //区间类型-下拉数据更新 - handleOptionsProcessing(data.length, 0, options); + handleOptionsProcessing(data.length, 0, options,type); console.log("当前表单", currentFormValues); } //添加工作日计费&&非工作计费-校验 - const handleValidation = (data) => { + const handleValidation = (data,type) => { let flag = true; //校验一,计算所有时间区间总和是否大于24小时,将时间戳转为小时,取整 - const totalTimes = data.reduce((total, isData) => { + let totalMinutes = 0; // 初始化总分钟数为0 + data.forEach((isData) => { if (isData.end == null || isData.start == null) { - message.error('时间字段不能为空'); + message.error("时间字段不能为空"); flag = false; + return; } - if (isData.end) { - const endTime = moment(isData.end); // 将 end 转换成 Moment 对象 - const startTime = moment(isData.start); // 将 start 转换成 Moment 对象 - const duration = moment.duration(endTime.diff(startTime)); // 计算时间差 - return total + duration.asMinutes(); // 将时间差累加到总时间中 - } else { - return total; - } - }, 0); - const totalHours = Math.floor(totalTimes/60); - const totalMinutes = Math.floor(totalTimes % 60); - console.log("当前区间时间总和", totalHours+":"+totalMinutes); // 输出每个 details 中总时间的数组 - if (totalHours != 23 && totalMinutes !=59) { + const endTime = moment(isData.end, "HH:mm"); + const startTime = moment(isData.start, "HH:mm"); + const duration = Math.ceil(endTime.diff(startTime, "seconds") / 60); + console.log("endTime:"+ endTime + "-- startTime:" + startTime+"-- duration:"+duration); // 输出每个 details 中总时间的数组 + totalMinutes += duration; // 将时间差累加到总分钟数中 + }); + const totalHours = Math.floor(totalMinutes / 60); + const remainingMinutes = totalMinutes % 60; + console.log("当前区间时间总和", totalHours + ":" + remainingMinutes); // 输出每个 details 中总时间的数组 + if (totalHours > 23 && totalMinutes > 59) { message.error('时间区间总和需要为23:59,请完善区间'); flag = false; - } + } return flag; } //添加区间 - const handleAddItemsClick = (i, z) => { + const handleAddItemsClick = (i, z,type) => { const currentFormValues = form.getFieldsValue(); + const data = type == 0 ? currentFormValues.rules[0].details : currentFormValues.rules[0].holiday + //如果第一个为基础时段则下一个改为周期计划 + newItems.type = data[i].items[0].type==0?2:0 //将新的区间数据合并到当前表单的值中 const updatedItems = [ - ...currentFormValues.rules[0].details.slice(0, i), + ...data.slice(0, i), { - ...currentFormValues.rules[0].details[i], - items: [...currentFormValues.rules[0].details[i].items, newItems] + ...data[i], + items: [...data[i].items, newItems] }, - ...currentFormValues.rules[0].details.slice(i + 1) + ...data.slice(i + 1) ]; - form.setFieldsValue({ - ...currentFormValues, - rules: [{ - ...currentFormValues.rules[0], - details: updatedItems - }] - }); - + if(type==0){ + form.setFieldsValue({ + ...currentFormValues, + rules: [{ + ...currentFormValues.rules[0], + details:updatedItems, + }] + }); + }else{ + form.setFieldsValue({ + ...currentFormValues, + rules: [{ + ...currentFormValues.rules[0], + holiday:updatedItems, + }] + }); + } //校验规则 - if (!handleItemsValidation(i, z)) { + if (!handleItemsValidation(i, z,data[i].items[0].type,type)) { return; } } //添加区间-校验 - const handleItemsValidation = (i, z, value) => { + const handleItemsValidation = (i, z, value,type) => { const currentFormValues = form.getFieldsValue(); // 校验1.当选择基础时段时,可以选择其他两项 // 校验2.当选择周期计划时,不能选择其他项 // 校验3.当选择按次收费金额,不能选择其他项 // 校验4.增加时段最高收费金额,当选择按次计费时时段最高收费金额输入框影藏 const data = value == 1 || value == 2 ? options.filter(op => op.value == value) : options; - handleOptionsProcessing(i, z, data)//统一区间类型下拉数据更新 + handleOptionsProcessing(i, z, data,type)//统一区间类型下拉数据更新 console.log("表单数据", currentFormValues); return true; } //区间类型-下拉数据更新 - const handleOptionsProcessing = (i, z, data) => { + const handleOptionsProcessing = (i, z, data,type) => { const key = i + '' + z; console.log(key, data); - setSelectOptions(prevOptions => ({ - ...prevOptions, - [key]: data - })); + if(type==0){ + setSelectOptions(prevOptions => ({ + ...prevOptions, + [key]: data + })); + }else{ + setSelectHolidayOptions(prevOptions => ({ + ...prevOptions, + [key]: data + })); + } + }; //区间类型-下拉数据查询-通过下标查询指定组件value - const getOptionsValueByIndex = (i, z) => { + const getOptionsValueByIndex = (i, z,type) => { const key = i + '' + z; - const value = selectOptions[key][z].value; + const value = type==0?selectOptions[key][z].value:selectHolidayOptions[key][z].value; console.log("getOptionsValueByIndex", value); return value; }; @@ -748,7 +796,7 @@ const FormModal = (props) => { > { - handleItemsValidation(i, z, value); + handleItemsValidation(i, z, value,1); }} style={{ width: 100, marginLeft: 10 }} - options={selectOptions[i + '' + z].map((option, index) => ({ + options={selectHolidayOptions[i + '' + z].map((option, index) => ({ value: option.value, label: option.label, key: index @@ -991,10 +1039,10 @@ const FormModal = (props) => { className="btm-box" > { - fields.length < 2 && getOptionsValueByIndex(i, z) != 1 && getOptionsValueByIndex(i, z) != 2 ? + fields.length < 2 && getOptionsValueByIndex(i, z,1) != 1 && getOptionsValueByIndex(i, z,1) != 2 ? - handleAddItemsClick(i, fields.length) + handleAddItemsClick(i, fields.length,1) } /> : fields.length > 1 ? index + 1, }, { title: '商户名称', @@ -253,7 +254,7 @@ function CategroyConf(props) { } else if (checkData.brand_name == '') { message.error('请选择物品类型') } else { - ajax.saveData(data).then((res) => { + ajax.saveCateData(data).then((res) => { if (res.status === 20000) { setAddVisible(false) getData(formData) diff --git a/src/pages/InRoadMgm/Stuff/StuffMgm/loadable.jsx b/src/pages/InRoadMgm/Stuff/StuffMgm/loadable.jsx index 68df8ba..39cfb93 100644 --- a/src/pages/InRoadMgm/Stuff/StuffMgm/loadable.jsx +++ b/src/pages/InRoadMgm/Stuff/StuffMgm/loadable.jsx @@ -62,11 +62,11 @@ function StuffMgm(props) { } //区域 const onChangeList = (value) => { - let arr =value - let arrStr=[] - let newArr=arr[arr.length-1] + let arr = value + let arrStr = [] + let newArr = arr[arr.length - 1] arrStr.push(newArr) - setFormData({ ...formData, region_id:arrStr }) + setFormData({ ...formData, region_id: arrStr }) } //状态 const handleStatus = (v) => { @@ -105,9 +105,10 @@ function StuffMgm(props) { //列表 const deployListColumns = [ { - title: '序号', - dataIndex: 'id', - key: 'id', + title: "序号", + width: 60, + align: "center", + render: (text, record, index) => index + 1, }, { title: '物品编号', @@ -187,11 +188,44 @@ function StuffMgm(props) { uid: '' }) const [getId, setGetId] = useState({}) + function findParents(treeData, id) { + let allparents = [] + if (treeData.length == 0) { + return + } + + let findele = (data, id) => { + if (!id) return + data.forEach((item, index) => { + if (item.id == id) { + allparents.unshift(item.id) + findele(treeData, item.pid) + + } else { + if (!!item.children) { + findele(item.children, id) + } + + } + }) + } + + findele(treeData, id) + return allparents + + } + // console.log('result', findParents(arrData, "1.3.1.1")) const translateBtn = (record) => { setGetId(record) setEditVisible(true) + console.log(record); + /** + * + */ + + console.log('region_id',findParents(getCanCaDer,record.region_id[0])); setGetEditData(Object.assign({}, getEditData, { - region_id: record.region_id, + region_id: findParents(getCanCaDer,record.region_id[0]), operatorid: record.operatorid, code: record.code, name: record.goods_name, @@ -345,9 +379,9 @@ function StuffMgm(props) { } const [checkData, setCheckData] = useState(param) const onChange = (newValue) => { - let arr =newValue - let arrStr=[] - let newArr=arr[arr.length-1] + let arr = newValue + let arrStr = [] + let newArr = arr[arr.length - 1] arrStr.push(newArr) setCheckData( Object.assign({}, checkData, { region_id: newArr }) @@ -415,9 +449,14 @@ function StuffMgm(props) { } const editBtn = () => { + let arr = getEditData.region_id + let arrStr = [] + let newArr = arr[arr.length - 1] + arrStr.push(newArr) let data = { ...getEditData, id: getId.id, + region_id: newArr } if (getEditData.region_id == '') { message.error('请选择区域') @@ -757,8 +796,8 @@ function StuffMgm(props) {
- { - let arr =newValue - let arrStr=[] - let newArr=arr[arr.length-1] - arrStr.push(newArr) setGetEditData( Object.assign({}, getEditData, { region_id: newValue }) ); diff --git a/src/pages/OperationCenter/CustomerServieMgm/CallbackSuggestion/loadable.jsx b/src/pages/OperationCenter/CustomerServieMgm/CallbackSuggestion/loadable.jsx index 67ef8c6..ee68ab7 100644 --- a/src/pages/OperationCenter/CustomerServieMgm/CallbackSuggestion/loadable.jsx +++ b/src/pages/OperationCenter/CustomerServieMgm/CallbackSuggestion/loadable.jsx @@ -647,12 +647,13 @@ function CallbackSuggestion(props) {
{res.replyTime}
{res.sysUserName}回复:{res.replyContent}
- {res.answerImgMap.length && + {res.answerImgMap.length ? res.answerImgMap.map(res => { return (
) }) + :'' }
diff --git a/src/services/search.js b/src/services/search.js index f4f5e11..705754a 100644 --- a/src/services/search.js +++ b/src/services/search.js @@ -451,6 +451,14 @@ const saveData = (params) => { data: params, }); }; +//物品管理--添加物品 +const saveCateData = (params) => { + return ajax({ + url: "/api/bpm/bpmgoodsbrand/add_brand_list", + type: "post", + data: params, + }); +}; //物品管理--编辑物品 const saveGoodEditData = (params) => { return ajax({ @@ -1140,6 +1148,7 @@ export default { editScheduling, deleteScheduling, saveEditData, + saveCateData, checkGoods, specialApproveApply, specialDeployApply,