ZaiZai 2 月之前
父節點
當前提交
4ce0443e32
共有 2 個文件被更改,包括 150 次插入13 次删除
  1. 3 0
      src/styles/view/project/edit-formula.scss
  2. 147 13
      src/views/project/list/edit-formula.vue

+ 3 - 0
src/styles/view/project/edit-formula.scss

@@ -307,6 +307,9 @@
             font-size: 14px;
             overflow: auto;
         }
+        .hc-formula-card-tag-date {
+            position: relative;
+        }
     }
 }
 

+ 147 - 13
src/views/project/list/edit-formula.vue

@@ -340,8 +340,30 @@
                                             </template>
                                         </div>
                                     </template>
-                                    <template v-else>
-                                        {{ item.name }} + {{ index }}
+                                    <template v-else-if="['日期偏移', '日期格式化', '下标取数', '判断'].includes(item.name)">
+                                        <div class="hc-formula-card-tag-date" :dataForm="setFormulaDataForm(item)">
+                                            <div class="hc-flex mb-8px">
+                                                <span class="mr-10px">日期增减</span>
+                                                <el-button size="small" type="info" @click="tagDateArgSelectEle(index)">选择参数</el-button>
+                                            </div>
+                                            <div class="relative mb-12px text-orange-6">输入某个固定日期/选择引用某个日期参数+/-固定天数(可选择引用某个参数值,也可输入固定值)</div>
+                                            <div class="hc-flex">
+                                                <el-tag v-if="tagDateArgName0" closable @close="delTagDateArgEle(item, '0')">{{ tagDateArgName0 }}</el-tag>
+                                                <el-input v-else value="" placeholder="引用参数名称" size="small" class="w-100px" @focus="curTagDateFocus(1)" />
+                                                <div class="hc-flex ml-10px mr-10px text-20px">/</div>
+                                                <div class="hc-flex w-160px">
+                                                    <el-date-picker v-model="tagDateArgDate0" class="block" type="date" size="small" placeholder="选择日期" format="YYYY 年 MM 月 dd 日" value-format="YYYY-MM-dd" @change="tagArgDateChange($event, item)" />
+                                                </div>
+                                                <el-select v-model="tagDateArgOperator" placeholder="请选择" size="small" class="ml-10px mr-10px w-50px" @change="tagDateArgOperatorChange($event, item)">
+                                                    <el-option label="+" value="+" />
+                                                    <el-option label="-" value="-" />
+                                                </el-select>
+                                                <el-tag v-if="tagDateArgName1" closable @close="delTagDateArgEle(item, '1')">{{ tagDateArgName1 }}</el-tag>
+                                                <el-input v-else value="" size="small" placeholder="参数名称" class="w-100px" @focus="curTagDateFocus(2)" />
+                                                <div class="hc-flex ml-10px mr-10px text-20px">/</div>
+                                                <el-input v-model="tagDateArgDate1" placeholder="输入值" size="small" class="w-100px" @change="tagDateArgChange($event, item)" />
+                                            </div>
+                                        </div>
                                     </template>
                                 </el-tab-pane>
                             </template>
@@ -1418,23 +1440,29 @@ const elementsIndex = ref({})
 const isSelectElementShow = ref(false)
 const selectingElements = (index, indexs) => {
     elementsIndex.value = { indexs: indexs, index: index }
+    isSelectEleType.value = 'select'
     isSelectElementShow.value = true
 }
 
 //选择了元素
 const setSelectElement = (item) => {
-    const { index, indexs } = elementsIndex.value
-    try {
-        const elementKey = item['tableElementKey'].replace('_key', ':key')
-        equationSelectEle.value.children[index].arguments[indexs] = {
-            id: item.id,
-            type: 'Element',
-            selected: false,
-            tableElementKey: elementKey,
-            name: item.k ? item.name : item.eName,
+    const type = isSelectEleType.value
+    if (type === 'select') {
+        const { index, indexs } = elementsIndex.value
+        try {
+            const elementKey = item['tableElementKey'].replace('_key', ':key')
+            equationSelectEle.value.children[index].arguments[indexs] = {
+                id: item.id,
+                type: 'Element',
+                selected: false,
+                tableElementKey: elementKey,
+                name: item.k ? item.name : item.eName,
+            }
+        } catch (error) {
+            console.log(error)
         }
-    } catch (error) {
-        console.log(error)
+    } else if (type === 'date') {
+        setTagDateArgEle(item)
     }
     selectElementClose()
 }
@@ -1442,6 +1470,8 @@ const setSelectElement = (item) => {
 //选择元素 关闭
 const selectElementClose = () => {
     isSelectElementShow.value = false
+    isSelectEleType.value = ''
+    selectTagDateIndex.value = -1
 }
 
 //当前元素
@@ -1451,6 +1481,109 @@ const setCurElement = (item, index, indexs) => {
     item.arguments[indexs] = tmp.children[index].arguments[indexs]
 }
 
+//获取数据
+const tagDateArgName0 = ref('')
+const tagDateArgDate0 = ref(null)
+const tagDateArgName1 = ref('')
+const tagDateArgDate1 = ref('')
+const setFormulaDataForm = (item) => {
+    let arg0 = item.arguments[0], arg1 = item.arguments[1]
+    // 第一个参数
+    if (isDataFormELe(arg0)) {
+        tagDateArgName0.value = arg0.name
+    } else {
+        tagDateArgDate0.value = arg0
+    }
+    // 第二个参数
+    if (isDataFormELe(arg1)) {
+        tagDateArgName1.value = arg1.name
+    } else {
+        tagDateArgDate1.value = arg1
+    }
+}
+
+const isDataFormELe = (ele) => {
+    return typeof ele == 'object' && ele != null
+}
+
+//删除
+const delTagDateArgEle = (item, type) => {
+    if (type === '0') {
+        tagDateArgName0.value = ''
+        item.arguments[0] = ''
+    } else if (type === '1') {
+        tagDateArgName1.value = ''
+        item.arguments[1] = ''
+    }
+}
+
+// 焦点
+const curTagDateIndex = ref(0)
+const curTagDateFocus = (type) => {
+    curTagDateIndex.value = type
+}
+
+// 选择日期
+const tagArgDateChange = (val, item) => {
+    tagDateArgName0.value = ''
+    item.arguments[0] = val
+}
+
+// 选择运算符
+const tagDateArgOperator = ref('+')
+const tagDateArgOperatorChange = (val, item) => {
+    const date1 = tagDateArgDate1.value || ''
+    if (isNullES(date1)) {
+        item.arguments[1] = date1
+        return
+    }
+    if (!isDataFormELe(item.arguments[1])) {
+        if (val === '-') {
+            item.arguments[1] = val + date1
+        } else {
+            item.arguments[1] = date1
+        }
+    }
+}
+
+const tagDateArgChange = (val, item) => {
+    tagDateArgName1.value = ''
+    item.arguments[1] = val
+}
+
+//选择参数
+const isSelectEleType = ref('')
+const selectTagDateIndex = ref(-1)
+const tagDateArgSelectEle = (index) => {
+    isSelectEleType.value = 'date'
+    selectTagDateIndex.value = index
+    isSelectElementShow.value = true
+}
+
+//设置
+const setTagDateArgEle = (item) => {
+    const type = curTagDateIndex.value
+    if (isNullES(type) || type <= 0) return
+    const index = selectTagDateIndex.value
+    let obj = {
+        id: item.id,
+        selected: false,
+        type: 'Element',
+        name: item.eName,
+        tableElementKey: item.tableElementKey,
+        children: [],
+    }
+    if (type === 1) {
+        equationSelectEle.value.children[index].arguments[0] = obj
+        tagDateArgName0.value = obj.name
+        tagDateArgDate0.value = null
+    } else if (type === 2) {
+        equationSelectEle.value.children[index].arguments[1] = obj
+        tagDateArgName1.value = obj.name
+        tagDateArgDate1.value = ''
+    }
+}
+
 //保存
 const submitLoading = ref(false)
 const submitClick = async () => {
@@ -1540,6 +1673,7 @@ const drawerClose = () => {
     isHandWritEle.value = false
     handWritText.value = ''
     handWritEleMap.value = {}
+    equationSelectEleCopy.value = {}
     isShow.value = false
     emit('close')
 }