YangYuGang
2025-03-08 1094c29e03ee0efc7121babda0532c8138aa801f
src/views/tigerprojects/system/lowcode/setting/pageDetail.vue
@@ -14,91 +14,14 @@
    content="这是低代码页面管理,在这能够根据实体类配置增删改功能页面。"
    @back="goBack"
  >
    <a-card title="查询条件配置" :bordered="false">
      <BasicForm @register="register">
        <template #add="{ field }">
          <a-button
            v-if="field"
            class="mt-1 ml-1"
            size="small"
            @click="handleSelecNew"
            preIcon="search|svg"
          />
          <EntityModal @register="registerNewAdd" @success="handleNewSuccess" />
        </template>
        <template #condAdd="{ field }">
          <a-button
            v-if="field"
            class="mt-1 ml-1"
            size="small"
            @click="condAdd"
            preIcon="add_blue|svg"
          />
        </template>
        <template #subtract="{ field }">
          <a-button
            v-if="field"
            class="mt-1 ml-1"
            size="small"
            @click="del(field)"
            preIcon="subtract|svg"
          />
        </template>
        <template #[item]="{ model, field }" v-for="(item, index) in searchSlots" :key="item">
          <a-input-group compact>
            <ApiSelect
              style="width: 25%"
              :api="getEntityPropertieList"
              :params="{ StartWith: getFieldsValue().ASSEMBLY_NAME, Namespace: 'Tiger.Model' }"
              v-model:value="model[field]"
              resultField="items"
              label-field="DisplayName"
              valueField="Name"
              @change="(value, option) => change(value, option, field)"
            />
            <a-input v-model:value="objInputs[field]" style="width: 55%" />
            <Select
              ref="select"
              v-model:value="searchSelectVals[field]"
              style="width: 20%"
              :options="options"
              :readonly="true"
              @change="(value, option) => searchOnChange(value, option, field)"
            />
          </a-input-group>
        </template>
        <template #[item]="{ model, field }" v-for="item in swSlots" :key="item">
          <a-switch v-model:checked="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchApiSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchParamsSlots" :key="item">
          <!-- <a-input v-model:value="model[field]" /> -->
            <CodeEditor v-model:value="model[field]" :mode="searchModeValue" :bordered="true"/>
        </template>
        <template #[item]="{ model, field }" v-for="item in searchResultFieldSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchLabelFieldSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchValueFieldSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchOptionsSlots" :key="item">
          <!-- <a-input v-model:value="model[field]" /> -->
          <CodeEditor v-model:value="model[field]" :mode="searchModeValue" :bordered="true"/>
        </template>
        <template #[item]="{ model, field }" v-for="item in searchOnChangeSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchPOptionsSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
      </BasicForm>
    </a-card>
    <a-card title="主表格配置" :bordered="false" class="!mt-5">
    <template #footer>
      <a-tabs default-active-key="detail" v-model:activeKey="currentKey">
        <a-tab-pane key="mainKey" tab="主表格配置" />
        <a-tab-pane key="searchKey" tab="查询条件配置" />
        <a-tab-pane key="crudKey" tab="增删改配置" />
      </a-tabs>
    </template>
    <a-card :bordered="false" v-show="currentKey == 'mainKey'">
      <div>
        <BasicForm @register="registerMain">
          <template #add="{ field }">
@@ -158,12 +81,98 @@
          </template>
          <template #[item]="{ model, field }" v-for="item in mainIaSlots" :key="item">
            <!-- <a-input v-model:value="model[field]" /> -->
            <CodeEditor v-model:value="model[field]" :mode="modeValue" :bordered="true"/>
            <CodeEditor v-model:value="model[field]" :mode="modeValue" :bordered="true" />
          </template>
        </BasicForm>
      </div>
    </a-card>
    <a-card title="增删改配置" :bordered="false" class="!mt-5">
    <a-card :bordered="false" v-show="currentKey == 'searchKey'">
      <BasicForm @register="register">
        <template #add="{ field }">
          <a-button
            v-if="field"
            class="mt-1 ml-1"
            size="small"
            @click="handleSelecNew"
            preIcon="search|svg"
          />
          <EntityModal @register="registerNewAdd" @success="handleNewSuccess" />
        </template>
        <template #condAdd="{ field }">
          <a-button
            v-if="field"
            class="mt-1 ml-1"
            size="small"
            @click="condAdd(false)"
            preIcon="add_blue|svg"
          />
        </template>
        <template #subtract="{ field }">
          <a-button
            v-if="field"
            class="mt-1 ml-1"
            size="small"
            @click="del(field)"
            preIcon="subtract|svg"
          />
        </template>
        <template #[item]="{ model, field }" v-for="(item, index) in searchSlots" :key="item">
          <a-input-group compact>
            <ApiSelect
              v-if="IsSearch == 'Y'"
              style="width: 25%"
              :api="getEntityPropertieList"
              :params="{ StartWith: getFieldsValue().ASSEMBLY_NAME, Namespace: 'Tiger.Model' }"
              v-model:value="model[field]"
              resultField="items"
              label-field="DisplayName"
              valueField="Name"
              @change="(value, option) => change(value, option, field)"
            />
            <a-input v-if="IsSearch == 'N'" v-model:value="objInputs2[field]" style="width: 25%" />
            <a-input v-model:value="objInputs[field]" style="width: 55%" />
            <Select
              ref="select"
              v-model:value="searchSelectVals[field]"
              style="width: 20%"
              :options="options"
              :readonly="true"
              @change="(value, option) => searchOnChange(value, option, field)"
            />
          </a-input-group>
        </template>
        <template #[item]="{ model, field }" v-for="item in swSlots" :key="item">
          <a-switch v-model:checked="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchApiSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchParamsSlots" :key="item">
          <!-- <a-input v-model:value="model[field]" /> -->
          <CodeEditor v-model:value="model[field]" :mode="searchModeValue" :bordered="true" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchResultFieldSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchLabelFieldSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchValueFieldSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchOptionsSlots" :key="item">
          <!-- <a-input v-model:value="model[field]" /> -->
          <CodeEditor v-model:value="model[field]" :mode="searchModeValue" :bordered="true" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchOnChangeSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
        <template #[item]="{ model, field }" v-for="item in searchPOptionsSlots" :key="item">
          <a-input v-model:value="model[field]" />
        </template>
      </BasicForm>
    </a-card>
    <a-card :bordered="false" v-show="currentKey == 'crudKey'">
      <BasicForm @register="registerCrud">
        <template #add="{ field }">
          <a-button
@@ -237,7 +246,7 @@
        </template>
        <template #[item]="{ model, field }" v-for="item in crudParamsSlots" :key="item">
          <!-- <a-input v-model:value="model[field]" /> -->
          <CodeEditor v-model:value="model[field]" :mode="searchModeValue" :bordered="true"/>
          <CodeEditor v-model:value="model[field]" :mode="searchModeValue" :bordered="true" />
        </template>
        <template #[item]="{ model, field }" v-for="item in crudResultFieldSlots" :key="item">
          <a-input v-model:value="model[field]" />
@@ -250,7 +259,7 @@
        </template>
        <template #[item]="{ model, field }" v-for="item in crudOptionsSlots" :key="item">
          <!-- <a-input v-model:value="model[field]" /> -->
          <CodeEditor v-model:value="model[field]" :mode="searchModeValue" :bordered="true"/>
          <CodeEditor v-model:value="model[field]" :mode="searchModeValue" :bordered="true" />
        </template>
        <template #[item]="{ model, field }" v-for="item in crudOnChangeSlots" :key="item">
          <a-input v-model:value="model[field]" />
@@ -269,7 +278,7 @@
</template>
<script lang="ts" setup>
  import { BasicForm, FormSchema, useForm } from '/@/components/Form';
  import { h, nextTick, onMounted, ref, unref } from 'vue';
  import { onMounted, ref, unref } from 'vue';
  import { Card, InputGroup, Select, Input, Switch } from 'ant-design-vue';
  import { ApiSelect } from '/@/components/Form/index';
  import { useRoute, useRouter } from 'vue-router';
@@ -278,7 +287,6 @@
  import { newFormSchema, crudSchemas, mainSchemas } from './setting.data';
  import { useTabs } from '/@/hooks/web/useTabs';
  import EntityModal from '/@/views/components/EntityModal.vue';
  import { buildUUID } from '/@/utils/uuid';
  import { SelectTypes } from 'ant-design-vue/es/select';
  import { useMultipleTabStore } from '/@/store/modules/multipleTab';
  import { useModal } from '/@/components/Modal';
@@ -287,11 +295,14 @@
  import { isNullOrEmpty, isNullOrUnDef } from '/@/utils/is';
  import { useUserStore } from '/@/store/modules/user';
  import { CodeEditor, MODE } from '/@/components/CodeEditor';
  import { Tabs } from 'ant-design-vue';
  const ACard = Card;
  const AInputGroup = InputGroup;
  const AInput = Input;
  const ASwitch = Switch;
  const ATabs = Tabs;
  const currentKey = ref('mainKey');
  const route = useRoute();
  const go = useGo();
  const objParams = ref(JSON.parse(decodeURI(route.params?.id as string)));
@@ -368,6 +379,7 @@
  /* 查询 */
  const SearchEntName = ref('');
  const objInputs = ref({} as { [key: string]: any });
  const objInputs2 = ref({} as { [key: string]: any });
  const searchProperties = ref([] as EntityPropertie[]);
  const searchSlots = ref([] as string[]);
  const searchSelectVals = ref({} as { [key: string]: any });
@@ -381,6 +393,7 @@
  const searchOnChangeSlots = ref([] as string[]);
  const searchPOptionsSlots = ref([] as string[]);
  const searchModeValue = ref<MODE>(MODE.JSON);
  const IsSearch = ref('Y');
  /* 主表 */
  const MainEntName = ref('');
  const mainSelectVals = ref({} as { [key: string]: any });
@@ -476,16 +489,21 @@
        order: '',
      }).then((data) => {
        /* 查询加载 */
        var searchForms = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON);
        const searchData = JSON.parse(data.Data.Items[0].SEARCH_FORM_JSON);
        var searchForms = isNullOrEmpty(searchData.fields) ? searchData : searchData.fields;
        SearchEntName.value = data.Data.Items[0].SEARCH_ASSY_NAME;
        setFieldsValue({ ASSEMBLY_NAME: data.Data.Items[0].SEARCH_ASSY_NAME });
        setFieldsValue({
          ASSEMBLY_NAME: data.Data.Items[0].SEARCH_ASSY_NAME,
          IsSearch: searchData.search ? 'Y' : 'N',
        });
        IsSearch.value = searchData.search ? 'Y' : 'N';
        searchForms = searchForms.filter(
          (item) =>
            !item['field'].toString().startsWith(SearchEntName.value) &&
            !item['field'].toString().endsWith('PSelect_0'),
        );
        for (const i in searchForms) {
          condAdd();
          condAdd(true);
          if (searchForms[i]['component'] == 'ApiSelect') {
            addApiSelectOption(`${SearchEntName.value}${Number(i) + 1}a`, 'search');
            setFieldsValue({
@@ -518,6 +536,7 @@
            [`Switch${Number(i) + 1}`]: searchForms[i]['ifShow'],
          });
          objInputs.value[`${SearchEntName.value}${Number(i) + 1}a`] = searchForms[i]['label'];
          objInputs2.value[`${SearchEntName.value}${Number(i) + 1}a`] = searchForms[i]['field'];
          searchSelectVals.value[`${SearchEntName.value}${Number(i) + 1}a`] = searchForms[i]['comp']
            ? searchForms[i]['comp']
            : searchForms[i]['component'];
@@ -589,6 +608,7 @@
        setFieldsValueMain({
          MainAssemblyName: MainEntName.value,
          BY_ORG: data.Data.Items[0].BY_ORG,
          CODE_NAME: data.Data.Items[0].CODE_NAME
        });
        for (const i in objs) {
          mainCondAdd();
@@ -619,7 +639,7 @@
      /* 查询条件Json */
      const Keys = Object.getOwnPropertyNames(values);
      var searchjsons = [];
      var searchjsons = { search: getFieldsValue().IsSearch == 'Y', fields: [] as any[] };
      var _json = {};
      var _n = 0;
      let firstField = '';
@@ -627,7 +647,12 @@
        console.log(`${k}:${Keys[k]}`);
        if (Keys[k].toString().startsWith(getFieldsValue().ASSEMBLY_NAME)) {
          firstField = Keys[k];
          _json['field'] = isNullOrEmpty(values[Keys[k]]) ? '' : values[Keys[k]];
          _json['field'] =
            getFieldsValue().IsSearch == 'N'
              ? objInputs2.value[Keys[k]]
              : isNullOrEmpty(values[Keys[k]])
                ? ''
                : values[Keys[k]];
          _json['label'] = objInputs.value[Keys[k]];
          _json['defaultValue'] = '';
          _json['component'] = searchSelectVals.value[Keys[k]];
@@ -662,7 +687,7 @@
            _json['component'] = 'Input';
            _json['comp'] = 'PoPSelect';
            _json['entityName'] = values[`PSelect${firstField}`];
            searchjsons.push(_json);
            searchjsons.fields.push(_json);
            _json = {};
            _json['field'] = `${firstField}PSelect_0`;
            _json['label'] = '1';
@@ -672,7 +697,7 @@
            _json['ifShow'] = true;
            _json['colSlot'] = `${firstField}add`;
          }
          searchjsons.push(_json);
          searchjsons.fields.push(_json);
          _json = {};
          _n = 0;
        }
@@ -680,7 +705,7 @@
      console.log(JSON.stringify(searchjsons));
      /* 主表格Json */
      const mKeys = Object.getOwnPropertyNames(mainvalues);
      var mjsons = [];
      var mjsons = [] as any[];
      var mjson = {};
      var i = 0;
      for (const k in mKeys) {
@@ -790,7 +815,7 @@
        }
      }
      console.log(JSON.stringify(cjsons));
      var entity: SYS_LOW_CODE = {
      var entity = {
        ID: objParams.value.ID,
        CREATE_USER: useUserStore().getUserInfo.userId as string,
        UPDATE_USER: useUserStore().getUserInfo.userId as string,
@@ -801,6 +826,7 @@
        CRUD_ASSY_NAME: getFieldsValueCrud().crudAssemblyName,
        SEARCH_ASSY_NAME: getFieldsValue().ASSEMBLY_NAME,
        BY_ORG: getFieldsValueMain().BY_ORG,
        CODE_NAME: getFieldsValueMain().CODE_NAME,
      };
      SaveEntity(entity, unref(objParams.value.Update) == '1', 'SYS_LOW_CODE').then((action) => {
        if (action.IsSuccessed) {
@@ -1320,8 +1346,10 @@
  const j = ref(1);
  /**
   * @description: 批量添加 查询配置
   * @param {boolean} isMounted - 是否挂载时进入方法
   */
  function condAdd() {
  function condAdd(isMounted: boolean) {
    IsSearch.value = isMounted ? IsSearch.value : getFieldsValue().IsSearch;
    appendSchemaByField(
      [
        {
@@ -1343,14 +1371,14 @@
          field: `InputNumber${n.value}`,
          component: 'InputNumber',
          label: '列宽',
          colProps: { span: 3 },
          colProps: { span: 4 },
        },
        {
          field: `${n.value}`,
          component: 'Input',
          label: ' ',
          slot: 'subtract',
          colProps: { span: 4 },
          colProps: { span: 3 },
        },
      ],
      '',
@@ -1480,7 +1508,7 @@
          label: '字段' + j.value,
          // required: true,
          slot: 'crudfac' + j.value,
          colProps: { span: 12 },
          colProps: { span: 11 },
        },
        {
          field: `Switch${j.value}`,
@@ -1500,7 +1528,7 @@
          field: `InputNumber${j.value}`,
          component: 'InputNumber',
          label: '列宽',
          colProps: { span: 3 },
          colProps: { span: 4 },
        },
        {
          field: `${j.value}`,