|
@@ -92,7 +92,9 @@
|
|
|
<el-button size="small" type="success" @click="addRowClick"
|
|
|
>新增</el-button
|
|
|
>
|
|
|
- <el-button size="small" type="primary">快捷导入</el-button>
|
|
|
+ <el-button size="small" type="primary" @click="uploadClick"
|
|
|
+ >快捷导入</el-button
|
|
|
+ >
|
|
|
<el-button size="small" type="warning">下载导入模板</el-button>
|
|
|
</template>
|
|
|
|
|
@@ -150,18 +152,71 @@
|
|
|
</hc-table>
|
|
|
</hc-card-item>
|
|
|
</hc-dialog>
|
|
|
+ <!-- 模板导入 -->
|
|
|
+ <hc-dialog v-model="fileModal" title="模板导入" @save="saveFileImport">
|
|
|
+ <hc-card-item>
|
|
|
+ <template #header>
|
|
|
+ <div class="text-sm text-red">
|
|
|
+ 提示:必须按照系统要求的模版格式上传,否则系统识别无效
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #extra>
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ @click="downLoadFile"
|
|
|
+ :loading="downloadLoading"
|
|
|
+ >下载导入模板</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ @click="importModalClick"
|
|
|
+ :loading="uploadsLoading"
|
|
|
+ >本地上传</el-button
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ <hc-table :column="fileTableColumn" :datas="fileTableData">
|
|
|
+ <template #elementAllowDeviation="{ row }">
|
|
|
+ <div class="flex">
|
|
|
+ <el-select
|
|
|
+ v-model="row.allow"
|
|
|
+ :popper-append-to-body="false"
|
|
|
+ placeholder="请选择"
|
|
|
+ >
|
|
|
+ <el-option :key="1" label="-" value="-"></el-option>
|
|
|
+ <el-option :key="2" label=">" value=">"></el-option>
|
|
|
+ <el-option :key="3" label="<" value="<"></el-option>
|
|
|
+ <el-option :key="4" label="≥" value="≥"></el-option>
|
|
|
+ <el-option :key="5" label="≤" value="≤"></el-option>
|
|
|
+ <el-option :key="6" label="±" value="±"></el-option>
|
|
|
+ <el-option
|
|
|
+ :key="7"
|
|
|
+ label="【】"
|
|
|
+ value="【】"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ <hc-table-input v-model="row.elementAllowDeviation" />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </hc-table>
|
|
|
+ </hc-card-item>
|
|
|
+ </hc-dialog>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { ref, watch } from "vue";
|
|
|
import { getDictionaryData, getDictionaryName } from "~src/utils/tools";
|
|
|
import mainApi from "~api/wbs/wbsforelement";
|
|
|
import { useAppStore } from "~src/store";
|
|
|
+import { HcDelMsg, HcUploadFileApi } from "hc-vue3-ui";
|
|
|
import {
|
|
|
deepClone,
|
|
|
formValidate,
|
|
|
getArrValue,
|
|
|
isNullES,
|
|
|
getObjValue,
|
|
|
+ downloadBlob,
|
|
|
} from "js-fast-way";
|
|
|
const store = useAppStore();
|
|
|
const userInfo = ref(store.getUserInfo);
|
|
@@ -324,6 +379,7 @@ const saveFormAndElementHandle = async () => {
|
|
|
formModel.value.nodeType = -1;
|
|
|
formModel.value.type = 2; // '1'节点 '2'表
|
|
|
formModel.value.parentId = node.value.id;
|
|
|
+ formModel.value.nodeName = node.value.nodeName;
|
|
|
for (let i = 0; i < editEleList.value.length; i++) {
|
|
|
if (!editEleList.value[i].eName) {
|
|
|
window.$message.warning("请填写第" + (i + 1) + "条元素名称");
|
|
@@ -346,9 +402,9 @@ const saveFormAndElementHandle = async () => {
|
|
|
});
|
|
|
submitLoading.value = true;
|
|
|
formModel.value.elementList = editEleList;
|
|
|
- const { error, code } = await mainApi.saveFormAndElement(
|
|
|
- formModel.value
|
|
|
- );
|
|
|
+ const { error, code } = await mainApi.saveFormAndElement({
|
|
|
+ ...formModel.value,
|
|
|
+ });
|
|
|
submitLoading.value = false;
|
|
|
if (!error && code === 200) {
|
|
|
window?.$message?.success("操作成功");
|
|
@@ -363,4 +419,66 @@ const dialogClose = () => {
|
|
|
isShow.value = false;
|
|
|
emit("close");
|
|
|
};
|
|
|
+const fileModal = ref(false);
|
|
|
+const uploadClick = () => {
|
|
|
+ fileModal.value = true;
|
|
|
+ fileTableData.value = [];
|
|
|
+};
|
|
|
+const fileTableColumn = [
|
|
|
+ { key: "elementName", name: "元素名称" },
|
|
|
+ { key: "elementType", name: "数据类型" },
|
|
|
+ { key: "elementLength", name: "长度" },
|
|
|
+ { key: "elementAllowDeviation", name: "允许偏差值" },
|
|
|
+ { key: "elementInspectionMethod", name: "检查方法和频率" },
|
|
|
+];
|
|
|
+const fileTableData = ref([]);
|
|
|
+const downloadLoading = ref(false);
|
|
|
+const downLoadFile = async () => {
|
|
|
+ downloadLoading.value = true;
|
|
|
+ const { error, disposition, res } = await mainApi.getExportTem();
|
|
|
+ //处理数据
|
|
|
+ downloadLoading.value = false;
|
|
|
+ if (!error) {
|
|
|
+ if (disposition) {
|
|
|
+ downloadBlob(res, disposition);
|
|
|
+ } else {
|
|
|
+ window.$message?.error("数据异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+const uploadsLoading = ref(false);
|
|
|
+const importModalClick = () => {
|
|
|
+ HcUploadFileApi({
|
|
|
+ multiple: false,
|
|
|
+ url: "/api/blade-manager/wbsFormElement/import-wbsElement",
|
|
|
+ target: "/api/blade-manager/wbsFormElement/import-wbsElement",
|
|
|
+ progress: () => {
|
|
|
+ uploadsLoading.value = true;
|
|
|
+ },
|
|
|
+ success: (file, res) => {
|
|
|
+ fileTableData.value = getArrValue(res.data);
|
|
|
+ },
|
|
|
+ error: (file) => {
|
|
|
+ uploadsLoading.value = false;
|
|
|
+ window.$message.error(`${file.name} 上传失败`);
|
|
|
+ },
|
|
|
+ finish: () => {
|
|
|
+ uploadsLoading.value = false;
|
|
|
+ window.$message.success("上传完成");
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
+const saveFileImport = () => {
|
|
|
+ fileModal.value = false;
|
|
|
+ fileTableData.value.forEach((ele) => {
|
|
|
+ editEleList.value.push({
|
|
|
+ eName: ele.elementName,
|
|
|
+ eAllowDeviation: ele.elementAllowDeviation,
|
|
|
+ eName: ele.elementInspectionMethod,
|
|
|
+ eLength: ele.elementLength,
|
|
|
+ eType: ele.elementType,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // editEleList.value
|
|
|
+};
|
|
|
</script>
|