瀏覽代碼

update

master
unknown 4 年之前
父節點
當前提交
724d2dd15b
共有 5 個檔案被更改,包括 188 行新增152 行删除
  1. +61
    -10
      src/services/template.js
  2. +27
    -6
      src/utils/request.js
  3. +83
    -100
      src/views/manage_system/template/index.vue
  4. +10
    -20
      src/views/manage_system/template_matrix.vue
  5. +7
    -16
      src/views/manage_system/template_mind.vue

+ 61
- 10
src/services/template.js 查看文件

@@ -1,28 +1,79 @@
import { fetchApi, wrapErrorHint } from '@/utils/request'; import { fetchApi, wrapErrorHint } from '@/utils/request';
import { firstCharToLowerCase, firstCharToUpperCase } from '@/utils/tool';
// import { firstCharToLowerCase, firstCharToUpperCase } from '@/utils/tool';


export async function createTemplate(params) {
return await fetchApi('template/createTemplate', params);
}


export async function queryTemplateList(){

export async function queryTemplateList() {
return await fetchApi('template/queryTemplateList'); return await fetchApi('template/queryTemplateList');
} }




/**
* 上传xmind文件
* @param {File} file
* @return {Object} 服务器解析的xmind节点数据
*/
export async function uploadXmind(file) { export async function uploadXmind(file) {
// const formData = new FormData(); // const formData = new FormData();
// formData.append('file', file, file.name); // formData.append('file', file, file.name);
return await fetchApi('template/uploadingXmind', file, { headers: {
'Content-Type': 'application/octet-stream',
} });
return await fetchApi('template/uploadingXmind', file, {
headers: {
'Content-Type': 'application/octet-stream',
}
});
} }

/**
* 创建模板
* @param {Object} params
*/
export async function createTemplate(params) {
return await fetchApi('template/createTemplate', params);
}
/**
* 模板详情
* @param {string} templateId
*/
export async function queryTemplateById(templateId) { export async function queryTemplateById(templateId) {
const res = await fetchApi('template/queryTemplateByTemplateId', { id: templateId }); const res = await fetchApi('template/queryTemplateByTemplateId', { id: templateId });
return wrapErrorHint(res); return wrapErrorHint(res);
} }

/**
* 查询模板被引用次数
* @param {string} templateId
*/
export async function queryTemplateQuoteCount(templateId) {
const res = await fetchApi('template/queryTemplateQuoteCount', { id: templateId });
return res;
}
/**
* 删除模板
* @param {string} templateId
*/
export async function deleteTemplate(templateId) {
const res = await fetchApi('template/deleteTemplate', { id: templateId });
return wrapErrorHint(res);
}
/**
* 更新模板
* @param {Object} params
*/
export async function updateTemplate(params) { export async function updateTemplate(params) {
const res = await fetchApi('template/updateTemplate', params); const res = await fetchApi('template/updateTemplate', params);
return wrapErrorHint(res); return wrapErrorHint(res);
}

/* jsmind节点树接口 */

export async function queryTemplateNodeByTemplateId(templateId) {
const res = await fetchApi('template/queryTemplateNodeByTemplateId', { templateId });
return wrapErrorHint(res);
}


/* 文件交换接口 */

export async function queryFileExchange(id){
const res = await fetchApi('template/queryFileExchange', { id });
return wrapErrorHint(res);
} }

+ 27
- 6
src/utils/request.js 查看文件

@@ -47,13 +47,34 @@ axios.interceptors.response.use(




export async function fetchApi(path, params, config) { export async function fetchApi(path, params, config) {

const [method, fullpath] = mapApiPathToFullPath(path); const [method, fullpath] = mapApiPathToFullPath(path);
const res = await (method === 'GET'
? axios.get(fullpath, { params }, config)
: axios.post(fullpath, params, config)
);
return res.data;
try {
const res = await (method === 'GET'
? axios.get(fullpath, { params }, config)
: axios.post(fullpath, params, config)
);
return res.data;
} catch(e) {
if(e.response && e.response.status) {
switch(e.response.status) {
case 404:
return {
Code: 404,
Msg: '找不到指定的服务',
};
default:
return {
Code: 503,
Msg: '服务异常,请稍微再试',
};
}
}
console.error(e);
return {
Code: 503,
Msg: '服务异常,请稍微再试',
};
}
} }


export function wrapErrorHint(response) { export function wrapErrorHint(response) {


+ 83
- 100
src/views/manage_system/template/index.vue 查看文件

@@ -2239,8 +2239,6 @@ export default {
*/ */
modifyTemplate() { modifyTemplate() {
var thisApp = this; var thisApp = this;

// 验证表单 // 验证表单
thisApp.$refs['tempform'].validate(async (valid) => { thisApp.$refs['tempform'].validate(async (valid) => {
if (!valid) return; if (!valid) return;
@@ -2259,7 +2257,7 @@ export default {
data.Temple.Disable = +data.Temple.Disable; data.Temple.Disable = +data.Temple.Disable;
data.Temple.Locked = +data.Temple.Locked; data.Temple.Locked = +data.Temple.Locked;
} }
console.log(data);
// console.log(data);
data.ChildIndustry = [data.IndLevel3, data.IndLevel4] data.ChildIndustry = [data.IndLevel3, data.IndLevel4]
.filter((a) => a) .filter((a) => a)
.join(","); .join(",");
@@ -2373,55 +2371,55 @@ export default {
/** /**
* 编辑模板 * 编辑模板
*/ */
async modifyTemplateOld() {
const currentTemplate = this.currentTemplateData;
debugger;
// async modifyTemplateOld() {
// const currentTemplate = this.currentTemplateData;
// debugger;


// if (this.selectDetailIndustryIndex === "") {
// const dataIndex = this.currentTemp.detailIndustryID;
// this.currentTemp.detailIndustryID = this.listSonIndustry[dataIndex].id;
// this.currentTemp.fullCode =
// this.listSonIndustry[dataIndex].data.fullCode +
// this.currentTemp.customCode;
// } else {
// const dataIndex = this.selectDetailIndustryIndex;
// this.currentTemp.detailIndustryID = this.listDetailIndustry[
// dataIndex
// ].id;
// this.currentTemp.fullCode =
// this.listDetailIndustry[dataIndex].data.fullCode +
// this.currentTemp.customCode;
// }
// this.currentTemp.listProperty = this.listTempProp;
// var thisApp = this;
// this.$axios({
// method: "put",
// url: encodeURI(process.env.API_HOST + "Templates/"),
// data: thisApp.currentTemp,
// })
// .then(function (response) {
// if (response.data.state == 1) {
// thisApp.$notify({
// title: "恭喜您",
// message: response.data.message,
// type: "success",
// offset: 100,
// duration: 2500,
// });
// } else {
// thisApp.$notify({
// title: "温馨提示",
// message: response.data.message,
// type: "success",
// offset: 100,
// duration: 5000,
// });
// }
// })
// .catch(function (error) {
// console.log(error);
// });
},
// // if (this.selectDetailIndustryIndex === "") {
// // const dataIndex = this.currentTemp.detailIndustryID;
// // this.currentTemp.detailIndustryID = this.listSonIndustry[dataIndex].id;
// // this.currentTemp.fullCode =
// // this.listSonIndustry[dataIndex].data.fullCode +
// // this.currentTemp.customCode;
// // } else {
// // const dataIndex = this.selectDetailIndustryIndex;
// // this.currentTemp.detailIndustryID = this.listDetailIndustry[
// // dataIndex
// // ].id;
// // this.currentTemp.fullCode =
// // this.listDetailIndustry[dataIndex].data.fullCode +
// // this.currentTemp.customCode;
// // }
// // this.currentTemp.listProperty = this.listTempProp;
// // var thisApp = this;
// // this.$axios({
// // method: "put",
// // url: encodeURI(process.env.API_HOST + "Templates/"),
// // data: thisApp.currentTemp,
// // })
// // .then(function (response) {
// // if (response.data.state == 1) {
// // thisApp.$notify({
// // title: "恭喜您",
// // message: response.data.message,
// // type: "success",
// // offset: 100,
// // duration: 2500,
// // });
// // } else {
// // thisApp.$notify({
// // title: "温馨提示",
// // message: response.data.message,
// // type: "success",
// // offset: 100,
// // duration: 5000,
// // });
// // }
// // })
// // .catch(function (error) {
// // console.log(error);
// // });
// },
/** /**
* 重命名文件夹 * 重命名文件夹
*/ */
@@ -2684,61 +2682,43 @@ export default {
* 删除模板 * 删除模板
*/ */
delTemplateClick: function () { delTemplateClick: function () {
var thisApp = this;
const currentTemplate = this.currentTemplateData;
this.$confirm( this.$confirm(
"您正在删除 [" + thisApp.currentTemp.tempName + "] 模板是否继续?",
"您正在删除 [" + currentTemplate.Temple.TempName + "] 模板是否继续?",
"删除", "删除",
{ {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning", type: "warning",
} }
).then(() => {
this.$axios({
method: "delete",
url: encodeURI(
process.env.API_HOST +
"Templates/" +
thisApp.currentTemp.templateID +
"/" +
thisApp.currentTemp.tempName +
"/" +
sessionStorage.userId
),
})
.then(function (response) {
thisApp.$notify({
title: "恭喜您",
message: response.data.message,
type: "success",
offset: 100,
duration: 2500,
});
thisApp.getTemplateData();
})
.catch(function (error) {
console.log(error);
});
).then(async () => {
const res = await services.deleteTemplate(currentTemplate.Temple.Id);
if( res.Code !== 0) return;
notify.success('删除成功');
this.getTemplateData();
}); });
}, },
/** /**
* 获取思维导图数据 * 获取思维导图数据
*/ */
getTemplateMindTree: function () {
var thisApp = this;
this.$axios({
method: "get",
url: encodeURI(
process.env.API_HOST + "templates/treenodes/" + thisApp.templateID
),
})
.then((response) => {
thisApp.listTemplateMindTree = response.data;
})
.catch((error) => {
console.log(error);
});
},
// async getTemplateMindTree() {
// debugger;
// const templateId = this.templateID;
// const res = await services.queryTemplateNodeByTemplateId(templateId);
// this.listTemplateMindTree = res.Data || [];
// // this.$axios({
// // method: "get",
// // url: encodeURI(
// // process.env.API_HOST + "templates/treenodes/" + thisApp.templateID
// // ),
// // })
// // .then((response) => {
// // thisApp.listTemplateMindTree = response.data;
// // })
// // .catch((error) => {
// // console.log(error);
// // });
// },
//导入Xmind模板的dialog //导入Xmind模板的dialog
importXmind: function () { importXmind: function () {
this.isImportDialog = true; this.isImportDialog = true;
@@ -3414,7 +3394,7 @@ export default {
name: this.templateName, name: this.templateName,
id: this.templateID, id: this.templateID,
data: this.treeMenuClickData, data: this.treeMenuClickData,
},
}
}); });
}, },
backmodlemain: function () { backmodlemain: function () {
@@ -3461,21 +3441,24 @@ export default {
* 查看样板文件 * 查看样板文件
*/ */
toNodeFile: function () { toNodeFile: function () {
debugger;
var templateId = this.currentTemp.templateID;
const currentTemplateData = this.currentTemplateData;
this.$router.push({ this.$router.push({
name: "system_template_file", name: "system_template_file",
params: { params: {
id: templateId,
data: this.currentTemp,
id: currentTemplateData.Temple.Id,
data: currentTemplateData.Temple,
}, },
}); });
}, },


/*---------- ----------*/ /*---------- ----------*/
async getTemplateDetail(templateId) { async getTemplateDetail(templateId) {
const res = await services.queryTemplateById(templateId);
const [res, countRes] = await Promise.all([
services.queryTemplateById(templateId),
services.queryTemplateQuoteCount(templateId),
]);
const mapIndIdToIndNode = this.mapIndIdToIndNode; const mapIndIdToIndNode = this.mapIndIdToIndNode;
this.nowCount = countRes.Data || 0;
if (res.Code !== 0) return; if (res.Code !== 0) return;
const { propertys, template } = res.Data; const { propertys, template } = res.Data;
// this.currentTemp = template; // this.currentTemp = template;


+ 10
- 20
src/views/manage_system/template_matrix.vue 查看文件

@@ -129,10 +129,9 @@
</template> </template>
<script> <script>
require("!vue-style-loader!css-loader!../../../public/static/css/totalAdmin.css");
require("!vue-style-loader!css-loader!../../../public/static/css/jsmind.css");
import Vue from "vue"; import Vue from "vue";
import fileUploader from "@/components/fileUploader/Index"; import fileUploader from "@/components/fileUploader/Index";
import * as services from '@/services/template';
Vue.use(fileUploader); Vue.use(fileUploader);
export default { export default {
data() { data() {
@@ -255,24 +254,15 @@
/** /**
* 获取矩阵文件夹权限数据 * 获取矩阵文件夹权限数据
*/ */
getMatirxPermission: function () {
var thisApp = this;
this.$axios({
method: "get",
url: encodeURI(
process.env.API_HOST + "templates/nodes/tree/" + this.tempId
)
})
.then(response => {
var data = response.data;
for (var i = 0; i < data.length; i++) {
thisApp.listMatirxPermission.push(data[i]);
this.getData(data[i]);
}
})
.catch(error => {
console.log(error);
});
async getMatirxPermission () {
const res = await services.queryFileExchange(this.tempId);
if(res.Code !== 0) return;
const data = res.Data || [];
debugger;
// for (var i = 0; i < data.length; i++) {
// this.listMatirxPermission.push(data[i]);
// this.getData(data[i]);
// }
}, },
/** /**
* 递归获获取矩阵数据 * 递归获获取矩阵数据


+ 7
- 16
src/views/manage_system/template_mind.vue 查看文件

@@ -24,7 +24,8 @@
</template> </template>
<script> <script>
require("!vue-style-loader!css-loader!../../../public/static/css/jsmind.css");
// require("!vue-style-loader!css-loader!../../../public/static/css/jsmind.css");
import * as services from "@/services/template";
const jsMind = window.jsMind; const jsMind = window.jsMind;
export default { export default {
data() { data() {
@@ -109,21 +110,11 @@
* @param {type} * @param {type}
* @return: * @return:
*/ */
getTemplateMindTree: function () {
var thisApp = this;
this.$axios({
method: "get",
url: encodeURI(
process.env.API_HOST + "templates/treenodes/" + this.tempId
)
})
.then(response => {
thisApp.listTemplateMindTree = response.data;
this.scanMind();
})
.catch(error => {
console.log(error);
});
async getTemplateMindTree() {
const templateId = this.tempId;
const res = await services.queryTemplateNodeByTemplateId('314820266176176128');
this.listTemplateMindTree = res.Data ? [res.Data] : [];
this.scanMind();
} }
} }
}; };

Loading…
取消
儲存