and design vue 高级查询

<template>
  <BasicModal
    v-bind="$attrs"
    @register="registerModal"
    :title="props.title"
    :useWrapper="true"
    width="1200px"
    okText="查询"
  >
    <BasicForm @register="registerForm">
      <!--   <template #add="{ field }">
        <Button v-if="Number(field) === 0" @click="add">+</Button>
        <Button v-if="field > 0" @click="del(field)">-</Button>
      </template> -->
      <template #add>
        <div style="width: 70%; float: left">
          <a-select
            :value="pipei"
            style="width: 92%; margin-bottom: 11px"
            @change="changeItempin($event)"
          >
            <a-select-option value="所有条件都要求匹配">所有条件都要求匹配</a-select-option>
            <a-select-option value="只匹配等于的条件">只匹配等于的条件</a-select-option>
            <a-select-option value="只匹配包含的条件">只匹配包含的条件</a-select-option>
          </a-select>

          <div class="c-o-d" v-for="(item, index) in connectArr" :key="index">
            <div class="c-o-d-i">
              <div class="c-o-d-i-1">
                <a-select
                  :value="item.linkPerson"
                  style="width: 160px"
                  placeholder="请选择查询条件"
                  @change="changeItem($event, item, 'linkPerson')"
                >
                  <a-select-option value="货号">货号</a-select-option>
                  <a-select-option value="产品类别">产品类别</a-select-option>
                  <a-select-option value="产品子类别">产品子类别</a-select-option>
                  <a-select-option value="产品名称">产品名称</a-select-option>
                  <a-select-option value="panel编号">panel编号</a-select-option>
                  <a-select-option value="panel简称">panel简称</a-select-option>
                  <a-select-option value="规格">规格</a-select-option>
                </a-select>
              </div>
              <div class="c-o-d-i-1">
                <a-select
                  class="inner-input"
                  :value="item.linkPersonPost"
                  style="width: 160px"
                  placeholder="请选择查询条件"
                  @change="changeItem($event, item, 'linkPersonPost')"
                >
                  <a-select-option value="等于">等于</a-select-option>
                  <a-select-option value="不等于">不等于</a-select-option>
                  <a-select-option value="小于">小于</a-select-option>
                  <a-select-option value="大于">大于</a-select-option>
                  <a-select-option value="包含">包含</a-select-option>
                  <a-select-option value="开头以">开头以</a-select-option>
                  <a-select-option value="结束以">结束以</a-select-option>
                  <a-select-option value="是空的">是空的</a-select-option>
                  <a-select-option value="小于或等于">小于或等于</a-select-option>
                </a-select>
              </div>
              <div class="c-o-d-i-1">
                <a-input
                  class="inner-input"
                  style="width: 160px"
                  :value="item.phoneNumbers"
                  @change="changeItem($event, item, 'phoneNumbers')"
                  placeholder="请填值"
                />
              </div>
            </div>
            <div class="c-o-d-o">
              <plus-circle-outlined
                @click="addCur(index)"
                class="addBtn"
                :style="{ color: '#08c', marginRight: '10px' }"
              />
              <delete-outlined
                @click="deleteCur(index)"
                v-if="index !== 0"
                :style="{ color: 'red' }"
              />
            </div>
          </div>
        </div>
        <div style="background: rgb(236, 236, 236); padding: 30px; width: 30%; float: right">
          <Card title="保存的查询">
            <div v-if="QUeryList.length > 0" v-for="(item, index) in QUeryList" :key="index">
              <CardGrid style="width: 100%; text-align: center" @click="CardClick(item)">{{
                item
              }}</CardGrid>
            </div>
            <div v-else>
              <Empty />
            </div>
          </Card>
        </div>
      </template>
    </BasicForm>

    <template #footer>
      <div>
        <!--       <a-button type="primary" style="float: left">重置</a-button> -->
        <a-button type="primary" style="float: left" @click="SaveQuery">保存</a-button>
      </div>
      <div style="height: 30px">
        <a-button type="primary" style="float: right; margin-right: 8px">查询</a-button>
        <a-button type="primary" style="float: right; margin-right: 8px">关闭</a-button>
      </div>
    </template>
  </BasicModal>
</template>
<script lang="ts" setup>
  import { ref, defineProps } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { BasicForm, useForm } from '/@/components/Form/index';
  import { updateInvoiceStateFormSchema } from './data';
  /*   import { updateInvoiceStateCommit } from './table'; */
  import { useMessage } from '/@/hooks/web/useMessage';
  import { useUserStore } from '/@/store/modules/user';
  import { useTableContext } from '/@/components/Table/src/hooks/useTableContext';
  import { Button } from '/@/components/Button';
  import { PlusCircleOutlined, DeleteOutlined } from '@ant-design/icons-vue';
  import { Card, CardGrid, Empty } from 'ant-design-vue';
  import { map } from 'lodash-es';
  const { createMessage } = useMessage();
  const table = useTableContext();
  const [
    registerForm,
    { appendSchemaByField, removeSchemaByField, resetFields, validate, setFieldsValue },
  ] = useForm({
    labelWidth: 100,
    baseColProps: { span: 24 },
    schemas: updateInvoiceStateFormSchema,
    showActionButtonGroup: false,
    actionColOptions: {
      span: 23,
    },
  });
  let connectArr = ref<Array<T>>([
    {
      linkPerson: '',
      linkPersonPost: '',
      phoneNumbers: '',
    },
  ]);

  const userStore = useUserStore();
  const usernames = userStore.getUserInfo.realName;

  const pipei = ref('所有条件都要求匹配');
  const props = defineProps({
    title: { type: String, default: '高级查询构造器' },
  });
  const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
    debugger;
    resetFields();
    setModalProps({ confirmLoading: false });
    console.log(data);

    connectArr.value = [
      {
        linkPerson: '',
        linkPersonPost: '等于',
        phoneNumbers: '',
      },
    ];
  });

  const addCur = (index: number) => {
    console.log('ApiContact >>> 添加联系人', connectArr);
    let obj = {
      linkPerson: '',
      linkPersonPost: '',
      phoneNumbers: '',
    };
    connectArr.value.splice(index + 1, 0, obj);
  };

  const deleteCur = (index: number) => {
    connectArr.value.splice(index, 1);
    console.log('ApiContact >>> 删除某个联系人', connectArr);
    /*    state.value = unref(connectArr); */
  };

  const changeItempin = (e: any) => {
    pipei.value = e;
  };
  const changeItem = (e: any, item: any, type: string) => {
    console.log('connectArr', e, item);
    if (type === 'linkPerson') {
      item.linkPerson = e;
    }
    if (type === 'linkPersonPost') {
      item.linkPersonPost = e;
    }
    if (type === 'phoneNumbers') {
      item.phoneNumbers = e.target.value;
    }
    console.log('ApiContact >>> 编辑联系人列表', connectArr);
  };
  const QUeryList = ref([]);
  let maps = new Map();
  async function SaveQuery() {
    maps.set(pipei.value, connectArr.value);
    QUeryList.value.push(pipei.value);
    debugger;
  }

  function CardClick(val) {
    var list = maps.get(val);
    connectArr.value = [];
    for (let index = 0; index < list.length; index++) {
      const element = list[index];

      let obj = {
        linkPerson: element.linkPerson,
        linkPersonPost: element.linkPersonPost,
        phoneNumbers: element.phoneNumbers,
      };
      connectArr.value.splice(index + 1, 0, obj);
    }
  }
</script>
<style lang="less" scoped>
  .c-o-d {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    padding-right: 10px;
    margin-bottom: 10px;
    margin-left: -23px;

    .c-o-d-i {
      flex: 9.5;

      display: flex;
      justify-content: space-between;
      padding-left: 22px;

      .c-o-d-i-1 {
        display: flex;
        align-items: center;
        // margin-right: 5px;
        height: 100%;

        .title {
          width: auto;
          text-align: right;
          display: block;
        }

        .inner-input {
          flex: 1;
        }
      }
    }

    .c-o-d-o {
      width: 38px;
      text-align: left;
      // border: 1px solid black;
      margin-left: 10px;
      // margin-bottom: 10px;
    }
  }
</style>

要在 Ant Design Vue 的 Steps 组件中正确渲染 Markdown 内容,可以通过以下方式实现: ### 解决方案 #### 1. 使用 `v-html` 渲染 HTML Markdown 需要先通过解析器转换为 HTML 字符串,然后再利用 Vue 的 `v-html` 属性将其注入到 DOM 中。以下是具体实现方法。 首先,在项目中引入并配置 Markdown 解析库(如 markdown-it),以便将 Markdown 转换为 HTML[^1]。 ```javascript // main.js 或相关初始化文件 import MarkdownIt from 'markdown-it'; const md = new MarkdownIt(); Vue.prototype.$md = md; // 将实例挂载到 Vue 原型上 ``` 接着,在组件中使用该工具来处理 Markdown 数据,并绑定至模板中的 `v-html` 属性。 ```vue <template> <a-steps :current="current"> <a-step v-for="(step, index) in steps" :key="index" :title="$md.render(step.title)" /> </a-steps> </template> <script> export default { data() { return { current: 0, steps: [ { title: '# Step One\nThis is the first step.' }, { title: '**Step Two**\nThis is the second step.' }, { title: '> Step Three\nThis is the final step.' } ] }; } }; </script> ``` 上述代码片段展示了如何动态加载 Markdown 并渲染其内容作为步骤标题的一部分。 --- #### 2. 自定义插槽扩展功能 如果仅依赖于默认属性无法满足需求,则可以考虑采用 **Ant Design Vue 提供的自定义插槽机制** 来增强灵活性。例如,针对每一步骤的内容区域单独设计布局逻辑。 下面的例子演示了如何结合 `slot-scope` 和外部函数完成更复杂的场景适配。 ```vue <template> <a-steps :current="current"> <a-step v-for="(step, index) in steps" :key="index"> <!-- 插入子级 slot --> <span slot="title" v-html="renderMarkdown(step.title)" /> </a-step> </a-steps> </template> <script> export default { methods: { renderMarkdown(content) { return this.$md.render(content); // 利用之前注册的方法执行转化操作 } }, data() { return { current: 0, steps: [ { title: '*Italic* and _underline_ text example' }, { title: '`Code block`\nand other elements...' }, { title: '- List item one\n- Another list entry here!' } ] }; } }; </script> ``` 此部分重点在于灵活运用框架特性的同时保持良好的可维护性和性能表现。 --- #### 3. Webpack 配置优化建议 为了进一步提升开发体验以及兼容性保障,推荐调整 Webpack 构建流程以支持更多高级选项。比如在基础配置文件 (`webpack.base.conf.js`) 中加入如下设置项即可开启对特定标记的支持: ```javascript module.exports = { module: { rules: [ { test: /\.md$/, use: ['raw-loader', 'markdown-it-vue-loader'] } ] } }; ``` 这样做的好处是可以直接导入 `.md` 文件而无需额外编码干预,简化工作流管理复杂度。 --- ### 注意事项 尽管上述方法有效解决了基本问题,但在实际应用过程中仍需注意安全性风险控制措施——即避免未经验证的数据直接嵌套进入页面结构以防 XSS 攻击隐患发生。 另外,请确认所使用的版本号是否匹配官方文档说明范围以免因 API 差异引起不必要的麻烦[^4]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值