vue elementUI Plus实现拖拽流程图,不引入插件,纯手写实现。

vue elementUI Plus实现拖拽流程图,不引入插件,纯手写实现。

    • 1.设计思路:
    • 2.设计细节
    • 3.详细代码实现

1.设计思路:

左侧button列表是要拖拽的组件。中间是拖拽后的流程图。右侧是拖拽后的数据列表。

我们拖动左侧组件放入中间的流程图中,并把button携带的数据信息带过来。

在这里插入图片描述

2.设计细节

左侧button组件列表可拖动并携带信息,当拖动到中间流程图上方时,流程图网格变色。当鼠标释放后,数据传递,流程图变化。

拖拽事件流程和参数
‌dragstart‌:当元素开始被拖拽时触发。
‌drag‌:元素正在被拖拽时持续触发(某些浏览器支持)。
‌dragend‌:当拖拽结束时触发。
‌dragenter‌:当拖拽的元素进入目标元素时触发。
‌dragover‌:当拖拽的元素在目标元素上移动时持续触发。
‌dragleave‌:当拖拽的元素离开目标元素时触发。
‌drop‌:当拖拽的元素在目标元素上释放时触发。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.详细代码实现

<template>
  <div class="scriptDraweAdd">
    <drawer-Box
      :drawerVisible="drawer.visible"
      :drawerFooter="drawer.drawerFooter"
      :direction="drawer.direction"
      :drawerSize="drawer.drawerSize"
      :drawerTitle="drawer.drawerTitle"
      @handleDrawerOpened="handleDrawerOpened"
      @handleDrawerClose="handleDrawerClose"
      @handleDrawerSubmit="handleDrawerSubmit"
    >
      <div class="main h100">
        <el-form ref="addFormRef" :model="editFrom" size="small" status-icon class="h100" label-width="auto">
          <el-row :gutter="0">
            <el-col>
              <el-row :gutter="10">
                <el-col :span="4" class="mb20 setting-title"><span>General settings</span></el-col>
                <el-col :span="10" class="mb20">
                  <el-form-item prop="projectName" :rules="rules.projectName">
                    <template v-slot:label
                      ><span>Project Name </span>
                      <el-tooltip effect="dark" content="Project Name" placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>

                    <el-input v-model="editFrom.projectName" placeholder="Project Name" clearable></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="10" class="mb20">
                  <el-form-item prop="version" :rules="rules.version">
                    <template v-slot:label
                      ><span>Version </span>
                      <el-tooltip effect="dark" content="Software Version" placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-input v-model="editFrom.version" placeholder="Software Version" clearable></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col>
              <el-row :gutter="10">
                <el-col :span="4" class="mb20"><span></span></el-col>
                <!-- <el-col :span="10" class="mb20">
                  <el-form-item prop="softwareName" :rules="rules.softwareName">
                    <template v-slot:label
                      ><span>Software Name </span>
                      <el-tooltip effect="dark" content="Software Name" placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-input v-model="editFrom.softwareName" placeholder="Software Name" clearable></el-input>
                  </el-form-item>
                </el-col> -->
                <el-col :span="10" class="mb20">
                  <el-form-item prop="function" :rules="rules.function">
                    <template v-slot:label
                      ><span>Function </span>
                      <el-tooltip effect="dark" content="Function of the script" placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-select v-model="editFrom.function" placeholder="Function">
                      <el-option v-for="item in functionOptions" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col>
              <el-row :gutter="10">
                <el-col :span="4" class="mb20 setting-title"><span>Advanced settings</span></el-col>
                <el-col :span="10" class="mb20">
                  <el-form-item label="" prop="maxRunTime" :rules="rules.maxRunTime">
                    <template v-slot:label
                      ><span>Max Run Time </span>
                      <el-tooltip effect="dark" content="The max run time of the script" placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-input-number type="number" v-model="editFrom.maxRunTime" :min="0" :max="1000" placeholder="Max Run Time" style="width: 100%" />
                  </el-form-item>
                </el-col>
                <el-col :span="10" class="mb20">
                  <el-form-item prop="startStopService" :rules="rules.startStopService">
                    <template v-slot:label
                      ><span>Start Stop Service </span>
                      <el-tooltip effect="dark" content="Service(s) needed to be pause during software installation, separate with commas." placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-input v-model="editFrom.startStopService" placeholder="Start Stop Service" clearable></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col>
              <el-row :gutter="10">
                <el-col :span="4" class="mb20"><span></span></el-col>
                <el-col :span="10" class="mb20">
                  <el-form-item prop="debugEnable" :rules="rules.debugEnable">
                    <template v-slot:label
                      ><span>Debug Enable </span>
                      <el-tooltip effect="dark" content="Used to enable logging." placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-switch v-model="editFrom.debugEnable" :active-value="true" :inactive-value="false" />
                  </el-form-item>
                </el-col>
                <el-col :span="10" class="mb20">
                  <el-form-item prop="defaultMsicLine" :rules="rules.defaultMsicLine">
                    <template v-slot:label
                      ><span>Default MSIC Line </span>
                      <el-tooltip effect="dark" content="Default MSI commands, used for each MSI installer." placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-input v-model="editFrom.defaultMsicLine" placeholder="Default MSIC Line" clearable></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col>
              <el-row :gutter="10">
                <el-col :span="4" class="mb20"><span></span></el-col>
                <el-col :span="10" class="mb20">
                  <el-form-item prop="uDriveMap" :rules="rules.uDriveMap">
                    <template v-slot:label
                      ><span>U-Drive Map </span>
                      <el-tooltip effect="dark" content="If the software stored on U-Drive." placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-switch v-model="editFrom.uDriveMap" :active-value="true" :inactive-value="false" />
                  </el-form-item>
                </el-col>
                <el-col :span="10" class="mb20">
                  <el-form-item label="IFS Script" prop="ifsScript" :rules="rules.ifsScript">
                    <template v-slot:label
                      ><span>IFS Script </span>
                      <el-tooltip effect="dark" content="If you need to run the script on your local computer." placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-switch v-model="editFrom.ifsScript" :active-value="true" :inactive-value="false" />
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col>
              <el-row :gutter="10">
                <el-col :span="4" class="mb20"><span></span></el-col>
                <!-- <el-col :span="10" class="mb20">
                  <el-form-item prop="patchCommands">
                    <template v-slot:label
                      ><span>Patch Commands </span>
                      <el-tooltip effect="dark" content="Used if need to install software to alternate folder." placement="top">
                        <i>
                          <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />
                        </i>
                      </el-tooltip>
                    </template>
                    <el-input v-model="editFrom.patchCommands" placeholder="Patch Commands" disabled></el-input>
                  </el-form-item>
                </el-col> -->
                <el-col :span="10" class="mb20">
                  <el-form-item label="Remarks" prop="remarks" :rules="rules.remarks">
                    <el-input v-model="editFrom.remarks" clearable placeholder="Remarks" :rows="2" type="textarea" />
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>

            <el-col>
              <el-row :gutter="10" class="custom-row-height">
                <el-col :span="8" class="mb20">
                  <div class="searchdiv">
                    <div style="display: flex">
                      <el-input style="margin-right: 10px" v-model="searchScriptName" placeholder="Script Name" @keyup.enter="getScriptList()" clearable></el-input>
                      <el-button @click="getScriptList()" type="primary">
                        <i> <svg-icon icon-class="icon_screen" class-name="iconfont font14" /> </i
                      ></el-button>
                    </div>
                    <div class="paramslabel">
                      <el-tooltip v-for="(item, index) in scriptList" :key="index" placement="top" raw-content :content="remarkHTML(item.remarks)">
                        <el-button draggable="true" @dragstart="dragstart($event, item)" @dragend="dragend($event, item)" class="buttondiv" :title="item.scriptName" type="primary">{{
                          item.scriptName
                        }}</el-button>
                      </el-tooltip>
                    </div>
                  </div>
                </el-col>
                <el-col :span="9" class="mb20">
                  <div class="flowdiv">
                    <div class="flowlabel">
                      <div>
                        <el-button class="buttondiv" type="primary">Start</el-button>
                        <div :class="['add-contain-div', overFlag.over0 ? 'add-contain-div-active' : '']" @dragover="dragOver($event, 'over0')" @drop="drop($event, 0)">
                          <svg-icon icon-class="downward_vertical_line" class="addline" />
                          <svg-icon icon-class="icon_add" class="addicon" />
                        </div>
                      </div>

                      <div v-for="(item, index) in editFrom.scriptList" :key="index" style="padding-left: 60px">
                        <!-- <el-button v-show="true" class="buttondiv2" type="primary">{{ item.gClientScriptId }}</el-button> -->
                        <el-input style="width: 180px" v-show="false" v-model="item.gClientScriptId" placeholder="gClientScriptId" readonly></el-input>

                        <el-tooltip placement="top" raw-content :content="remarkHTML(item.remarks)">
                        <el-button class="buttondiv" type="primary">{{ item.scriptName }}</el-button>
                        </el-tooltip>
                        <el-button type="text" @click="deleteMethod(index)" class="deletebutton">
                          <svg-icon icon-class="icon_delete2" class="deleteline" />
                        </el-button>

                        <div style="padding-right: 60px" @dragover="dragOver($event, 'over' + (index + 1))" @drop="drop($event, index + 1)">
                          <div :class="['add-contain-div', overFlag['over' + (index + 1)] ? 'add-contain-div-active' : '']">
                            <svg-icon icon-class="downward_vertical_line" class="addline" />
                            <svg-icon icon-class="icon_add" class="addicon" />
                          </div>
                        </div>
                      </div>

                      <el-button class="buttondiv" type="primary">End</el-button>
                    </div>
                  </div>
                </el-col>

                <el-col :span="7" class="mb20" style="min-width:350px">
                  <div v-for="(item2, index2) in editFrom.scriptList" :key="index2 + 'params'">
                    <div class="paramsdiv">
                      <div class="params-title-parent">
                        <el-form-item
                          ><span style="margin-left: 10px; font-weight: bold">{{ item2.scriptName }}</span></el-form-item
                        >
                      </div>
                      <div class="paramsdiv-content">
                        <el-form-item label-width="auto" label="Order No."> <el-input style="width: 100%" v-model="item2.orderNum" placeholder="Order No." readonly></el-input></el-form-item>
                        <el-form-item label="CmdRCOpt" label-width="auto" :prop="`scriptList[${index2}].cmdRcopt`" :rules="[{ required: true, message: `Please input  CmdRCOpt`, trigger: 'change' }]">
                          <el-select v-model="item2.cmdRcopt" placeholder="CmdRCOpt" disabled style="width: 100%">
                            <el-option v-for="item3 in cmdRCOptOptions" :key="item3.value" :label="item3.label" :value="item3.value" />
                          </el-select>
                        </el-form-item>
                        <div v-for="(item, index) in item2.paramslist" :key="index2 + '_' + index">
                          <el-form-item v-show="false" label="Order No." label-width="140px">
                            <el-input style="width: 100%" v-model="item.index" placeholder="Order No." readonly></el-input>
                          </el-form-item>
                          <div v-if="item.dataType === 'String'" class="paramsdiv-params">
                            <el-form-item
                              :prop="`scriptList[${index2}].paramslist[${index}].value`"
                              :rules="[{ required: true, message: `Please input  ${item.name}`, trigger: 'blur' }]"
                              label-width="auto"
                            >
                              <template v-slot:label
                                ><span>{{ item.name }}</span>
                                <el-tooltip effect="dark" :content="item.remarks" placement="top">
                                  <i> <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />&nbsp;&nbsp; </i>
                                </el-tooltip>
                                <el-tag style="margin-right: 0px !important; margin-top: 3px !important" type="primary" class="mr12" effect="light" round>{{ item.dataType }}</el-tag>
                              </template>

                              <el-input style="width: 100%" v-model="item.value" :placeholder="item.name"></el-input>
                            </el-form-item>
                          </div>

                          <div v-if="item.dataType === 'Int'" class="paramsdiv-params">
                            <el-form-item
                              :prop="`scriptList[${index2}].paramslist[${index}].value`"
                              :rules="[{ required: true, message: `Please input  ${item.name}`, trigger: 'change' }]"
                              label-width="auto"
                            >
                              <template v-slot:label
                                ><span>{{ item.name }}</span>
                                <el-tooltip effect="dark" :content="item.remarks" placement="top">
                                  <i> <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />&nbsp;&nbsp; </i>
                                </el-tooltip>
                                <el-tag style="margin-right: 0px !important; margin-top: 3px !important" type="primary" class="mr12" effect="light" round>{{ item.dataType }}</el-tag>
                              </template>

                              <!-- <el-input style="width: 100%" v-model="item.value" :placeholder="item.name"></el-input> -->
                              <el-input-number type="number" v-model="item.value" :placeholder="item.name" style="width: 100%" />
                            </el-form-item>
                          </div>

                          <div v-if="item.dataType === 'Boolean'" class="paramsdiv-params">
                            <el-form-item
                              :prop="`scriptList[${index2}].paramslist[${index}].value`"
                              :rules="[{ required: true, message: `Please input  ${item.name}`, trigger: 'change' }]"
                              label-width="auto"
                            >
                              <template v-slot:label
                                ><span>{{ item.name }}</span>
                                <el-tooltip effect="dark" :content="item.remarks" placement="top">
                                  <i> <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />&nbsp;&nbsp; </i>
                                </el-tooltip>
                                <el-tag style="margin-right: 0px !important; margin-top: 3px !important" type="primary" class="mr12" effect="light" round>{{ item.dataType }}</el-tag>
                              </template>

                              <el-switch v-model="item.value" :active-value="true" :inactive-value="false" :value="false" :disabled="index === 0" />
                            </el-form-item>
                          </div>
                          <div v-if="item.dataType === 'File'" class="paramsdiv-params">
                            <el-form-item
                              :label="item.name"
                              :placeholder="item.name"
                              :prop="`scriptList[${index2}].paramslist[${index}].fileList`"
                              :rules="[{ required: true, message: `Please upload file`, validator: validator, trigger: 'change' }]"
                              label-width="auto"
                            >
                              <template v-slot:label
                                ><span>{{ item.name }}</span>
                                <el-tooltip effect="dark" :content="item.remarks" placement="top">
                                  <i> <svg-icon icon-class="icon_ notes_info" class-name="iconfont font14" />&nbsp;&nbsp; </i>
                                </el-tooltip>
                                <el-tag style="margin-right: 0px !important; margin-top: 3px !important" type="primary" class="mr12" effect="light" round>{{ item.dataType }}</el-tag>
                              </template>

                              <el-upload
                                :disabled="item.isOriginalFile === 1"
                                :action="upload.action"
                                :headers="upload.headers"
                                :limit="upload.limit"
                                multiple
                                v-model:file-list="item.fileList"
                                :on-success="(res) => handleUploadSuccess(res, item, index)"
                                :on-remove="(uploadFile, uploadFiles) => handleRemove(uploadFile, uploadFiles, item, index)"
                                :before-upload="(file) => beforeAvatarUpload(file, item, index)"
                                :on-exceed="(uploadFile, uploadFiles) => handleExceed(uploadFile, uploadFiles, item, index)"
                                :on-preview="(uploadFile) => handlePreview(uploadFile, item, index)"
                              >
                                <el-button :disabled="item.fileList && item.fileList.length > 0" type="primary">Click to upload</el-button>
                                <template #tip>
                                  <div class="el-upload__tip">.ps1, .txt files with a size less than 2M</div>
                                </template>
                              </el-upload>
                            </el-form-item>
                            <el-form-item v-show="false" label="File Name" label-width="140px">
                              <el-input style="width: 80%" v-model="item.fileName" placeholder="File Name" readonly></el-input>
                            </el-form-item>
                            <el-form-item :prop="`scriptList[${index2}].paramslist[${index}].fileContent`" label-width="140px" style="margin-top: -20px">
                              <el-input
                                v-show="false"
                                type="textarea"
                                readonly
                                style="width: 100%"
                                v-model="item.fileContent"
                                placeholder="File Content"
                                :autosize="{ minRows: 3, maxRows: 10000 }"
                              ></el-input>
                            </el-form-item>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </el-col>
              </el-row>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </drawer-Box>
  </div>
</template>
<script>
import { toRefs, reactive, onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import DrawerBox from '../drawer/index'
import gClientApi from '@/api/gClientApi'
import gClientManagementApi from '@/api/gClientManagementApi'
import { removeProperty } from '@/utils/validate'
import { Session } from '@/utils/storage'
export default {
  name: 'GclientScriptMenagement',
  emits: ['handleSearch', 'handleClose', 'downScriptFile'],
  components: {
    DrawerBox
    // vxeTable
  },
  props: {
    drawer: {
      type: Object,
      default: () => {
        return {}
      }
    },
    GclientScriptMenagement: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  setup(props, ctx) {
    // 列表数组 接口返回的数据
    const vxeData = reactive({
      tableList: []
    })

    const addFormRef = ref(null)
    // 复选框数组
    const vxeList = reactive({
      checkList: []
    })
    const useTableHeader = reactive({})
    const state = reactive({
      upload: {
        action: process.env.VUE_APP_API_URL + '/portal/v1/GClientScript/scriptUpload',
        headers: {
          Authorization: Session.get('token')
        },
        accept: '.ps1, .txt',
        fileSize: 2,
        limit: 1
      },
      functionOptions: [
        { lable: 'Install', value: 'Install' },
        { lable: 'Uninstall', value: 'Uninstall' }
      ],
      typeOptions: [
        { label: 'String', value: 'String' },
        { label: 'Int', value: 'Int' },
        { label: 'Boolean', value: 'Boolean' },
        { label: 'File', value: 'File' }
      ],
      cmdRCOptOptions: [
        { label: 'Continue running', value: 0 },
        { label: 'Command failed,stop running', value: 1 },
        { label: 'Command failed,continue running', value: 2 }
      ],

      editFrom: {
        softwareName: '',
        version: '',
        projectName: '',
        // applicationName: '',
        patchCommands: '',
        maxRunTime: 90,
        startStopService: '',
        debugEnable: true,
        defaultMsicLine: '',
        uDriveMap: false,
        function: 'Install',
        ifsScript: false,
        remarks: '',
        scriptList: []
      },

      editFrom2: {
        softwareName: '',
        version: '',
        projectName: '',
        // applicationName: '',
        patchCommands: '',
        maxRunTime: 90,
        startStopService: '',
        debugEnable: true,
        defaultMsicLine: '',
        uDriveMap: false,
        function: 'Install',
        ifsScript: false,
        remarks: '',
        scriptList: []
      },
      scriptList: [],
      rules: {
        softwareName: [{ required: true, message: 'Please input Software Name', trigger: 'blur' }],
        version: [{ required: true, message: 'Please input Version', trigger: 'blur' }],
        projectName: [{ required: true, message: 'Please input Project Name', trigger: 'blur' }],
        // applicationName: [{ required: true, message: 'Please input Application Name', trigger: 'blur' }],
        patchCommands: [{ required: true, message: 'Please input Patch Commands', trigger: 'blur' }],
        maxRunTime: [{ required: true, message: 'Please input Max Run Time', trigger: 'blur' }],
        startStopService: [{ required: true, message: 'Please input Start Stop Service', trigger: 'blur' }],
        debugEnable: [{ required: true, message: 'Please input Debug Enable', trigger: 'blur' }],
        defaultMsicLine: [{ required: true, message: 'Please input Default MSIC Line', trigger: 'blur' }],
        uDriveMap: [{ required: true, message: 'Please input U-Drive Map', trigger: 'blur' }],
        function: [{ required: true, message: 'Please input Function', trigger: 'blur' }],
        ifsScript: [{ required: true, message: 'Please input IFS Script', trigger: 'blur' }]
      },
      paramsIndex: 1,
      searchScriptName: '',
      overFlag: {}
    })

    const getParamsName = (index) => {
      return `Param Name ${index + 1}`
    }

    const getParamsRules = (name) => {
      let msg = `Please input  ${name}`
      let tips = [{ required: true, message: msg, trigger: 'blur' }]
      return tips
    }

    const validator = (rule, value, callback) => {
      if (value && value.length > 0) {
        callback() // 表示验证通过
      } else {
        callback(new Error('length>0'))
      }
    }

    const deleteMethod = (index) => {
      const newArray = state.editFrom.scriptList.filter((element, index2) => index2 !== index)
      state.editFrom.scriptList = newArray
      state.editFrom.scriptList.forEach((val, index) => {
        val.orderNum = index + 1
      })
    }

    const SubmitList = (checkData) => {
      vxeList.checkList = checkData
    }
    // 数据提交
    const handleDrawerSubmit = async () => {
      addFormRef.value.validate(async (valid) => {
        if (valid) {
          const data = { ...state.editFrom }
          console.log(data)
          const res = await gClientManagementApi.add(data)
          if (res.code === 200) {
            resetForm(addFormRef.value)
            handleDrawerClose()
            ctx.emit('handleSearch')

            ElMessage({
              showClose: true,
              message: res.message,
              type: 'success'
            })
          } else {
            ElMessage({
              showClose: true,
              message: res.message,
              type: 'error'
            })
          }
        } else {
          console.log('error submit!')
          return false
        }
      })
    }

    // Drawer 打开时触发
    const handleDrawerOpened = () => {
      getScriptList()
    }

    // Drawer 关闭
    const handleDrawerClose = () => {
      state.editFrom = JSON.parse(JSON.stringify(state.editFrom2))
      ctx.emit('handleClose', 'Add')
    }
    const dragstart = (event, item) => {
      // console.log(event, item)
      // 使用 dataTransfer 对象传递JSON数据作为文本
      event.dataTransfer.setData('text/plain', JSON.stringify(item))
    }

    const dragend = (event, item) => {
      state.overFlag = {}
    }

    const dragOver = (event, name) => {
      // 阻止浏览器默认操作,允许drop事件发生
      event.preventDefault()
      state.overFlag = {}
      state.overFlag[name] = true
      // console.log(state.overFlag)
    }

    const drop = (event, index) => {
      // 阻止浏览器默认操作
      event.preventDefault()

      // 获取传递的JSON数据
      const jsonData = event.dataTransfer.getData('text/plain')
      // 解析JSON数据
      const data = JSON.parse(jsonData)

      state.overFlag = {}
      state.editFrom.scriptList.splice(index, 0, data)

      state.editFrom.scriptList = JSON.parse(JSON.stringify(state.editFrom.scriptList))
      state.editFrom.scriptList.forEach((val, index) => {
        val.orderNum = index + 1
      })
      console.log('get', state.editFrom.scriptList)
    }
    // 表单 Reset
    const resetForm = (formEl) => {
      if (!formEl) return
      formEl.resetFields()
      state.editFrom = JSON.parse(JSON.stringify(state.editFrom2))
    }

    const handleBlur = () => {
      // console.log('1111', state.editFrom.scriptList)
    }

    const getScriptList = async () => {
      // console.log(columns.value)
      // console.log(exportColumns.value)
      // 条件检索
      const query = removeProperty(JSON.parse(JSON.stringify({ scriptName: state.searchScriptName })))
      console.log(query)
      const res = await gClientApi.getDownLoadData({ ...query })
      if (res.code === 200) {
        const _arr = res.data.map((item) => {
          let paramslist = []
          if (item.paramsNameList && item.paramsNameList.length > 0) {
            item.paramsNameList.map((element) => {
              if (null !== element.value && undefined !== element.value && '' !== element.value) {
                paramslist.push({ ...element })
              } else {
                paramslist.push({ ...element, value: '', fileList: [], fileName: '', fileContent: '' })
              }
            })
          }
          item.paramslist = paramslist
          item.gClientScriptId = item.id
          let _item = { ...item }
          return _item
        })
        state.scriptList = JSON.parse(JSON.stringify(_arr))
        // ElMessage({
        //   message: res.message,
        //   type: 'success'
        // })
      } else {
        ElMessage({
          message: res.message,
          type: 'error'
        })
      }
    }

    // 上传图片验证
    const beforeAvatarUpload = (file, item, index) => {
      // 校检文件类型
      if (state.upload.accept) {
        // 文件后缀名
        let fileExtension = ''
        if (file.name.lastIndexOf('.') > -1) {
          fileExtension = file.name.slice(file.name.lastIndexOf('.') + 1)
        }
        const isTypeOk = state.upload.accept.indexOf(fileExtension) > -1
        if (!isTypeOk) {
          ElMessage({
            showClose: true,
            message: `The file format is incorrect. Please upload the file in ${state.upload.accept} format!`,
            type: 'error'
          })
          return false
        }
      }
      // 校检文件大小
      if (state.upload.fileSize) {
        const isLt = file.size / 1024 / 1024 < state.upload.fileSize
        if (!isLt) {
          ElMessage({
            showClose: true,
            message: `The uploaded file size cannot exceed ${state.upload.fileSize} MB!`,
            type: 'error'
          })
          return false
        }
      }
      return true
    }

    // 文件个数超出
    const handleExceed = (files, uploadFiles, item, index) => {
      ElMessage({
        showClose: true,
        message: `The number of uploaded files cannot exceed ${state.upload.limit} !`,
        type: 'error'
      })
    }

    // 文件上传成功时的钩子
    const handleUploadSuccess = (res, item, index) => {
      switch (res.code) {
        case 200:
          item.fileContent = res.data.fileContent
          item.fileName = res.data.fileName
          item.value = res.data.fileName
          // ruleForm.systemScreenshot = res.data.filePath
          ElMessage({
            showClose: true,
            message: res.message,
            type: 'success'
          })
          break

        case 401:
          Session.clear()
          window.location.reload()
          break

        case 403:
          Session.clear()
          window.location.reload()
          break

        default:
          ElMessage({
            showClose: true,
            message: res.message,
            type: 'error'
          })
      }
    }

    // 文件列表移除文件时的钩子
    const handleRemove = (uploadFile, uploadFiles, item, index) => {
      item.fileList = []
      item.fileContent = ''
      item.fileName = ''
      item.value = ''
    }
    // 点击文件列表中已上传的文件时的钩子
    const handlePreview = (uploadFile, item, index) => {
      // ctx.emit('downScriptFile', item)
    }
    const handleChange = (value, item) => {
      console.log(value, item)
    }

    const fileChange = (name, item) => {
      addFormRef.value.validateField(name, (val) => {
        if (!val) {
          return true
        } else {
          return false
        }
      })
    }

    const remarkHTML = (remark) => {
      // return remark.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
      if (remark) {
        return remark.replace(/\n|\r\n/g, '<br/>').replace(/ /g, '  ')
      }
      return ''
    }

    onMounted(() => {})
    return {
      ...toRefs(state),
      ...toRefs(vxeData),
      ...toRefs(vxeList),
      ...toRefs(useTableHeader),
      addFormRef,
      handleDrawerOpened,
      handleDrawerClose,
      handleDrawerSubmit,
      SubmitList,
      getParamsName,
      getParamsRules,
      deleteMethod,
      resetForm,
      getScriptList,
      dragstart,
      dragOver,
      drop,
      dragend,
      handleBlur,
      validator,
      beforeAvatarUpload,
      handleExceed,
      handleUploadSuccess,
      handleRemove,
      handleChange,
      handlePreview,
      fileChange,
      remarkHTML
    }
  }
}
</script>
<style lang="scss">
.scriptDraweAdd {
  // .setting-title {
  //   font-size: var(--el-form-label-font-size);
  //   color: var(--el-text-color-regular);
  //   height: 32px;
  //   line-height: 32px;
  //   padding: 0 12px 0 0;
  //   box-sizing: border-box;
  //   font-weight: bold;
  // }
  .drawer_title {
    font-weight: bold;
    margin-bottom: 16px;
  }

  .name-parent {
    display: flex;
    .title {
      font-weight: bold;
      width: 5px;
      height: 30px;
      margin-right: 5px;
      background-color: var(--color-primary) !important;
    }
    .blank {
      font-weight: bold;
      width: 5px;
      height: 30px;
      margin-right: 5px;
    }
    .label {
      flex: 1;
    }
  }

  .title {
    font-weight: bold;
    width: 5px;
    height: 30px;
    margin-right: 5px;
    background-color: var(--color-primary) !important;
  }

  .no-label .el-form-item__label {
    display: none;
  }

  .custom-row-height {
    /* 使用calc()函数从100vh中减去100px */
    // height: calc(100vh - 600px);
    min-height: 400px;
    .searchdiv {
      flex: 1;
      height: 100%;
      padding: 5px;
      border-radius: 4px;
      border: 1px solid #cccccc;
      box-sizing: border-box;
      .paramslabel {
        margin-top: 10px;
        display: flex; /* 启用Flexbox布局 */
        flex-direction: column; /* 子元素纵向排列 */
        justify-content: center; /* 子元素在父容器内水平居中(纵向上的居中) */
        align-items: center; /* 子元素在父容器内水平居中(横向上的居中) */
        .buttondiv {
          width: 60%;
          // min-width: 290px;
          max-width: 300px;
          height: 30px;
          margin: 7px;
          color: var(--color-primary) !important;
          background-color: #fff;
          border: 2px solid var(--color-primary);
        }
      }
    }
    .flowdiv {
      min-width: 500px;
      flex: 1;
      height: 100%;
      padding: 5px;
      border-radius: 4px;
      border: 1px solid #cccccc;
      box-sizing: border-box;
      .deletebutton {
        width: 48px;
        height: 32px;
        color: #606266 !important;
        .deleteline {
          width: 40px;
          height: 32px;
          color: #606266 !important;
        }
      }

      .flowlabel {
        margin-top: 10px;
        display: flex; /* 启用Flexbox布局 */
        flex-direction: column; /* 子元素纵向排列 */
        justify-content: center; /* 子元素在父容器内水平居中(纵向上的居中) */
        align-items: center; /* 子元素在父容器内水平居中(横向上的居中) */

        .add-contain-div {
          margin: -5px 5px -5px 5px;
          height: 60px;
          // background-color: var(--color-primary) !important;
          position: relative;
          .addline {
            position: absolute;
            width: 100%;
            height: 100%;
            color: #606266;
          }

          .addicon {
            position: absolute;
            width: 40%;
            height: 40%;
            color: #606266;
            margin-left: 130px;
            margin-top: 17px;
          }
        }

        .add-contain-div-active {
          border: 1px dashed var(--color-primary);
        }
        .buttondiv {
          width: 300px;
          height: 30px;
          margin: 5px;
          color: var(--color-primary) !important;
          background-color: #fff;
          border: 2px solid var(--color-primary);
        }

        .buttondiv2 {
          width: 250px;
          height: 30px;
          margin: 5px;
          color: var(--color-primary) !important;
          background-color: #fff;
          border: 2px solid var(--color-primary);

          &:hover {
            border: 2px solid var(--el-color-primary);
            background-color: var(--el-color-primary) !important;
            color: #fff !important;
          }
          &:active,
          &:focus {
            background-color: var(--color-primary) !important;
            color: #fff !important;
          }
        }
        // .deletediv{
        //   float:right;
        //   right:0px;
        //   width:auto;
        // }
      }
    }
  }

  .paramsdiv {
   min-width: 500px;
    flex: 1 1 0%;
    height: 100%;

    border-radius: 2px;
    border: 1px solid #cccccc;
    box-sizing: border-box;
    margin-left: 0px;
    padding-bottom: 25px;
    margin-bottom: 20px;
    margin-right: 0px;
    .paramsdiv-content {
      padding: 5px;
      .paramsdiv-params {
        margin-bottom: 30px;
      }
    }
    .params-title-parent {
      padding: 5px 5px 5px 5px;
      display: flex;
      justify-content: space-between;
      /* 如果需要,可以添加以下样式以确保父 div 占据整个宽度 */
      width: 100%;
      border-bottom: 1px solid rgb(230, 230, 230);

      background-color: #fbfbfb;
      margin-bottom: 20px;

      .child {
        /* 你可以根据需要添加子 div 的样式 */
      }

      .left {
        /* 你可以在这里添加左边子 div 的特定样式 */
      }

      .right {
        /* 你可以在这里添加右边子 div 的特定样式 */
      }
    }
  }
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/948740.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Spring boot 项目 Spring 注入 代理 并支持 代理对象使用 @Autowired 去调用其他服务

文章目录 类定义与依赖注入方法解析createCglibProxy注意事项setApplicationContext 方法createCglibProxy 方法 类定义与依赖注入 Service: 标识这是一个 Spring 管理的服务类。ApplicationContextAware: 实现该接口允许你在类中获取 ApplicationContext 对象&#xff0c;从而…

应用程序越权漏洞安全测试总结体会

应用程序越权漏洞安全测试总结体会 一、 越权漏洞简介 越权漏洞顾名思议超越了自身的权限去访问一些资源&#xff0c;在OWASP TOP10 2021中归类为A01&#xff1a;Broken Access Control&#xff0c;其本质原因为对访问用户的权限未进行校验或者校验不严谨。在一个特定的系统或…

JAVA:Spring Boot 集成 Quartz 实现分布式任务的技术指南

1、简述 Quartz 是一个强大的任务调度框架&#xff0c;允许开发者在应用程序中定义和执行定时任务。在 Spring Boot 中集成 Quartz&#xff0c;可以轻松实现任务的调度、管理、暂停和恢复等功能。在分布式系统中&#xff0c;Quartz 也支持集群化的任务调度&#xff0c;确保任务…

改善 Kibana 中的 ES|QL 编辑器体验

作者&#xff1a;来自 Elastic Marco Liberati 随着新的 ES|QL 语言正式发布&#xff0c;Kibana 中开发了一种新的编辑器体验&#xff0c;以帮助用户编写更快、更好的查询。实时验证、改进的自动完成和快速修复等功能将简化 ES|QL 体验。 我们将介绍改进 Kibana 中 ES|QL 编辑器…

【深度学习入门_基础篇】线性代数本质

开坑本部分主要为基础知识复习&#xff0c;新开坑中&#xff0c;学习记录自用。 学习目标&#xff1a; 熟悉向量、线性组合、线性变换、基变换、矩阵运算、逆函数、秩、列空间、零空间、范式、特征指、特征向量等含义与应用。 强烈推荐此视频&#xff1a; 【官方双语/合集】…

【SpringBoot】当 @PathVariable 遇到 /,如何处理

1. 问题复现 在解析一个 URL 时&#xff0c;我们经常会使用 PathVariable 这个注解。例如我们会经常见到如下风格的代码&#xff1a; RestController Slf4j public class HelloWorldController {RequestMapping(path "/hi1/{name}", method RequestMethod.GET)publ…

VBA(Visual Basic for Applications)编程|excel|一系列网址或文件路径快速转换为可点击的超链接

很多时候&#xff0c;我们需要把导入的数据某一列转换成超链接&#xff0c;比如URL形式的列。 那么&#xff0c;大批量的情况下&#xff0c;无疑一个个手动点击是非常愚蠢的办法&#xff0c;这个时候我们就需要VBA编程来编写宏&#xff0c;通过编写宏来简化这些手动操作并不现…

小程序开发全解析 快速构建高效应用的核心指南

内容概要 小程序开发是当前数字世界中炙手可热的领域&#xff0c;吸引了无数开发者和企业的关注。随着技术的进步&#xff0c;小程序成为了提升用户体验、增强品牌曝光以及增加客户互动的重要工具。了解小程序的基本概念&#xff0c;就像是打开了一扇通往新世界的大门。 在这…

SQL—Group_Concat函数用法详解

SQL—Group_Concat函数用法详解 在LC遇见的一道很有趣的SQL题&#xff0c;有用到这个函数&#xff0c;就借这道题抛砖引玉&#xff0c;在此讲解一下group_concat函数的用法。&#x1f923; GROUP_CONCAT([DISTINCT] expression [ORDER BY expression] [SEPARATOR separator])…

Edge Scdn的应用场景有哪些?

酷盾安全Edge Scdn 具备强大的安全防护能力&#xff0c;通过多层防御机制&#xff0c;如防火墙、DDoS 攻击防护、入侵检测和防御、数据加密等&#xff0c;有效抵御各种网络攻击&#xff0c;包括 DDoS 攻击、CC 攻击、SQL 注入攻击、XSS 跨站脚本攻击等&#xff0c;保障网站和应…

流光效果

1、流光效果是什么 在 Unity Shader 中的流光效果是一种动态的视觉效果&#xff0c;通常用于给材质增加一种闪光或光线移动的效果&#xff0c;使物体表面看起来像是有光在流动。这种效果常用于武器光效、能量护盾、传送门等等&#xff0c;可以让物体看起来更加生动富有科技感 …

滑动窗口——串联所有单词的子串

一.题目描述 30. 串联所有单词的子串 - 力扣&#xff08;LeetCode&#xff09; 二.题目解析 题目前提&#xff1a;s是一个字符串&#xff0c;words是一个字符串数组&#xff0c;里面所有的字符串的长度都是相等的。 题目要求&#xff1a;找到s中的一段连续的子串&#xff0…

【微软,模型规模】模型参数规模泄露:理解大型语言模型的参数量级

模型参数规模泄露&#xff1a;理解大型语言模型的参数量级 关键词&#xff1a; #大型语言模型 Large Language Model #参数规模 Parameter Scale #GPT-4o #GPT-4o-mini #Claude 3.5 Sonnet 具体实例与推演 近日&#xff0c;微软在一篇医学相关论文中意外泄露了OpenAI及Claud…

SpringBoot Maven 项目 pom 中的 plugin 插件用法整理

把 SpringBoot Maven 项目打包成 jar 文件时&#xff0c;我们通常用到 spring-boot-maven-plugin 插件。 前面也介绍过&#xff0c;在 spring-boot-starter-parent POM 和 spring-boot-starter POM 中都有插件的管理&#xff0c;现在我们就撸一把构建元素中插件的用法。 一、…

UE5AI感知组件

官方解释&#xff1a; AI感知系统为Pawn提供了一种从环境中接收数据的方式&#xff0c;例如噪音的来源、AI是否遭到破坏、或AI是否看到了什么。 AI感知组件&#xff08;AIPerception Component&#xff09;是用于实现游戏中的非玩家角色&#xff08;NPC&#xff09;对环境和其…

【数据仓库】hive on Tez配置

hive on Tez 搭建 前提是hive4.0hadoop3.2.2数仓已搭建完成&#xff0c;现在只是更换其执行引擎 为Tez。搭建可参考【数据仓库】hive hadoop数仓搭建实践文章。 Tez 下载 下载地址 https://archive.apache.org/dist/tez/ 官网地址 https://tez.apache.org/releases/apac…

finereport动态数据源插件教程2

场景&#xff1a; 模板中有多个数据集&#xff0c;只需要其中一个数据集按照不同的参数显示不同数据库的数据。 模板制作&#xff1a; 两个数据集ds1&#xff0c;ds2&#xff0c;ds1的绑定到参数面板的下拉框上&#xff0c;ds2显示到模板正文中&#xff0c;现在需要ds1根据不同…

Java通过谷歌邮箱Gmail直接发送邮件的三种方式

错误 Connected to the target VM, address: 127.0.0.1:52082, transport: socketException in thread "main" javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.gmail.com, port: 587, response: [EOF] at com.sun.mail.smtp.SMTPTransp…

WSDM 2025 | 时间序列(time series)论文总结

AWSDM 2025于2025年3月10号到14号在德国汉诺威举行&#xff08;Hannover, Germany&#xff09; 本文总结了WSDM 2024有关时间序列&#xff08;time series&#xff09;的相关论文&#xff0c;如有疏漏&#xff0c;欢迎大家补充。&#xff08;没有时空数据相关的论文&#xff0…

反直觉导致卡关-迫击炮谜题

这个谜题&#xff0c;在两周目中先后卡了我至少三个小时&#xff0c;先后缓慢装填并发射迫击炮弹尝试了数百次。 一周目卡了很久&#xff0c;稀里糊涂的过了&#xff0c;想不到二周目还会卡那么久。 研究了很多播主的攻略&#xff0c;但还是一头雾水&#xff0c; 直到分析其…