|
@@ -266,6 +266,38 @@ luckysheet.luckysheetextendData = luckysheetextendData;
|
|
|
|
|
|
export { luckysheet };
|
|
|
|
|
|
+const getColSign = (celldata, days) => {
|
|
|
+ // 定义44927代表的日期基准
|
|
|
+ let baseDate = new Date(1900, 0, 1); // 1900年1月1日
|
|
|
+ let resultDate = new Date(baseDate);
|
|
|
+ resultDate.setDate(baseDate.getDate() + days);
|
|
|
+ const curMonth = resultDate.getMonth() + 1;
|
|
|
+ const curYear = resultDate.getFullYear();
|
|
|
+ let colNum = 0;
|
|
|
+ celldata.forEach((item) => {
|
|
|
+ if (item.r == 5 && item.c >= 12 && item.c <= 84) {
|
|
|
+ let itemDate = new Date(baseDate);
|
|
|
+ itemDate.setDate(baseDate.getDate() + item.v.v);
|
|
|
+ const month = itemDate.getMonth() + 1;
|
|
|
+ const year = itemDate.getFullYear();
|
|
|
+ if (month == curMonth && year == curYear) colNum = item.c;
|
|
|
+ return month;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //获取日期列数据
|
|
|
+ return colNum;
|
|
|
+};
|
|
|
+
|
|
|
+function numberToExcelColumn(num) {
|
|
|
+ let result = "";
|
|
|
+ while (num >= 0) {
|
|
|
+ const remainder = num % 26;
|
|
|
+ result = String.fromCharCode(65 + remainder) + result;
|
|
|
+ num = Math.floor(num / 26) - 1;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+}
|
|
|
+
|
|
|
// function initSheet(sheet, authority, permissions) {
|
|
|
function initSheet(sheet, authority) {
|
|
|
let permissions = {
|
|
@@ -293,7 +325,7 @@ function initSheet(sheet, authority) {
|
|
|
sheet.config.authority = authority;
|
|
|
} else {
|
|
|
let canEditRangeList = [];
|
|
|
-
|
|
|
+
|
|
|
if (sheet.name == "PSR") {
|
|
|
canEditRangeList = [
|
|
|
{
|
|
@@ -354,19 +386,47 @@ function initSheet(sheet, authority) {
|
|
|
sheet.status = 0;
|
|
|
}
|
|
|
// 预计回款权限
|
|
|
- if (permissions["func-psr-02"]) {
|
|
|
+ if (permissions["func-actual-02"]) {
|
|
|
canEditRangeList.push({
|
|
|
hintText: "",
|
|
|
sqref: "$A$3:$CF$3",
|
|
|
});
|
|
|
}
|
|
|
// 实际回款权限
|
|
|
- if (permissions["func-psr-03"]) {
|
|
|
+ if (permissions["func-actual-03"]) {
|
|
|
canEditRangeList.push({
|
|
|
hintText: "",
|
|
|
sqref: "$A$4:$CF$4",
|
|
|
});
|
|
|
}
|
|
|
+ // 日期列已发生:成本会计;
|
|
|
+ if (permissions["func-actual-04"]) {
|
|
|
+ //获取当前表单日期
|
|
|
+ const days = sheet.celldata.find((item) => item.r == 1 && item.c == 3)
|
|
|
+ ?.v.v;
|
|
|
+ //获取跟当前日期匹配的 col
|
|
|
+ const colNum = getColSign(sheet.celldata, days);
|
|
|
+ //转化成 ABC
|
|
|
+ const colSign = numberToExcelColumn(colNum);
|
|
|
+ canEditRangeList.push({
|
|
|
+ hintText: "",
|
|
|
+ sqref: `$M$7:$${colSign}$248`,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 日期列未发生:采购经理;
|
|
|
+ if (permissions["func-actual-05"]) {
|
|
|
+ //获取当前表单日期
|
|
|
+ const days = sheet.celldata.find((item) => item.r == 1 && item.c == 3)
|
|
|
+ ?.v.v;
|
|
|
+ //获取跟当前日期匹配的 col
|
|
|
+ const colNum = getColSign(sheet.celldata, days);
|
|
|
+ //转化成 ABC 不包括当前列
|
|
|
+ const colSign = numberToExcelColumn(colNum + 1);
|
|
|
+ canEditRangeList.push({
|
|
|
+ hintText: "",
|
|
|
+ sqref: `$${colSign}$7:$CF$248`,
|
|
|
+ });
|
|
|
+ }
|
|
|
} else if (sheet.name == "清单") {
|
|
|
// 隐藏项目经理预算
|
|
|
if (!permissions["func-list-01"]) {
|