文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 53cd5b0b by 郭婉茹

option那里templete的获取还有点问题

parent d93380d3
...@@ -20,39 +20,65 @@ ...@@ -20,39 +20,65 @@
</template> </template>
<script> <script>
import PiecesTable from './PiecesTable' import PiecesTable from "./PiecesTable"
export default { export default {
name: 'on-going-task-detail', name: "on-going-task-detail",
components: { components: {
PiecesTable PiecesTable
}, },
data () { data() {
return { return {
task: null task: null
} };
}, },
beforeMount () { beforeMount() {
this.task = JSON.parse(decodeURIComponent(this.$route.params.task)) this.task = JSON.parse(decodeURIComponent(this.$route.params.task))
}, },
methods: { methods: {
doOption (file, type) { doOption(file, type) {
//console.log("this.task"+JSON.stringify(this.task)); var params = {
//console.log("this.file"+JSON.stringify(file)); file: encodeURIComponent(JSON.stringify(file)),
var params = { file: encodeURIComponent(JSON.stringify(file)), task: encodeURIComponent(JSON.stringify(this.task)) } task: encodeURIComponent(JSON.stringify(this.task))
var self = this };
function goto (path) { var self = this;
function goto(path) {
self.$router.push({ name: path, params }) self.$router.push({ name: path, params })
} }
switch (type) { switch (type) {
case '文本': goto('SelectText'); break case "文本":
case '图片': goto('image'); break if (
case '图层': goto('layer'); break file.url
case '表格': goto('table') .split("")
.reverse()
.join("")
.substring(0, 4)
.split("")
.reverse()
.join("") == "xlsx"
)
goto("table")
else if (
file.url
.split("")
.reverse()
.join("")
.substring(0, 3)
.split("")
.reverse()
.join("") == "txt"
)
goto("SelectText")
break
case "图片":
goto("image");
break
case "图层":
goto("layer");
} }
} }
} }
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -59,15 +59,28 @@ ...@@ -59,15 +59,28 @@
<!-- 弹窗--> <!-- 弹窗-->
<el-dialog title="请标注" :visible.sync="ifAlert"> <el-dialog title="请标注" :visible.sync="ifAlert">
<div style="overflow: auto;height: 50vh"> <div style="overflow: auto;height: 50vh">
<el-select v-model="value" placeholder="选择标注对象"> <!-- 实体 -->
<!-- <el-select v-model="value" placeholder="选择标注对象">
<el-option <el-option
v-for="item in options" v-for="item in options"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:value="item.label" :value="item.label"
></el-option> ></el-option>
</el-select>-->
<el-select v-model="value" placeholder="模板选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.label"
></el-option>
<el-option>
<el-button type="text" @click="dialogFormVisible = true">自定义模板</el-button>
</el-option>
</el-select> </el-select>
<!--el-button type="primary" @click="handleOption">新建</el-button--> <!--el-button type="primary" @click="handleOption">新建</el-button-->
<!-- 属性 -->
<el-tree <el-tree
:data="treeData" :data="treeData"
show-checkbox show-checkbox
...@@ -82,6 +95,36 @@ ...@@ -82,6 +95,36 @@
<el-button type="primary" style="margin-top: 30px" @click="handleCheckChange">确定</el-button> <el-button type="primary" style="margin-top: 30px" @click="handleCheckChange">确定</el-button>
</el-dialog> </el-dialog>
<!-- 弹窗--> <!-- 弹窗-->
<!-- 弹窗之子哈哈哈哈 -->
<el-dialog title="自定义模板" :visible.sync="dialogFormVisible">
<el-form :model="form">
<el-form-item label="模板名称" :label-width="formLabelWidth">
<el-input v-model="form.name" autocomplete="off"></el-input>
</el-form-item>
<input v-model="mm" placeholder="输入实体或属性" />
<!-- 树状结构-->
<div class="block">
<el-tree
:data="this.entityList"
node-key="id"
default-expand-all
:expand-on-click-node="false"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>{{ node.label }}</span>
<span>
<el-button type="text" size="mini" @click="() => append(data,mm)">Append</el-button>
<el-button type="text" size="mini" @click="() => remove(node, data)">Delete</el-button>
</span>
</span>
</el-tree>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="rePage(0)">取 消</el-button>
<el-button type="primary" @click="rePage(1)">确 定</el-button>
</div>
</el-dialog>
</div> </div>
</el-main> </el-main>
</el-container> </el-container>
...@@ -113,36 +156,6 @@ export default { ...@@ -113,36 +156,6 @@ export default {
// 文章列表 // 文章列表
textData: [], textData: [],
// templete // templete
// treeDataExample: [
// {
// label: "宏观稳定性",
// children: [
// {
// label: "不稳定"
// },
// {
// label: "基本稳定"
// },
// {
// label: "稳定"
// }
// ]
// },
// {
// label: "确定性程度",
// children: [
// {
// label: "确定"
// },
// {
// label: "基本确定"
// },
// {
// label: "不确定"
// }
// ]
// }
// ],
treeData: [], treeData: [],
defaultProps: { defaultProps: {
...@@ -153,72 +166,52 @@ export default { ...@@ -153,72 +166,52 @@ export default {
ifAlert: false, // 弹窗 ifAlert: false, // 弹窗
// 实体 // 实体
value: "", value: "",
// optionsExample: [ options: [
// { {
// value: "选项1", value: "选项1",
// label: "滑坡" label: "滑坡"
// }, },
// { {
// value: "选项2", value: "选项2",
// label: "山体" label: "山体"
// }, },
// { {
// value: "选项3", value: "选项3",
// label: "河流" label: "河流"
// }, },
// { {
// value: "选项4", value: "选项4",
// label: "时间" label: "时间"
// } }
// ], ],
options: [], // 弹窗
dialogFormVisible: false,
form: {
name: "",
region: "",
date1: "",
date2: "",
delivery: false,
type: [],
resource: "",
desc: ""
},
// table // table
tableData: [] tableData: []
}; };
}, },
beforeMount() { beforeMount() {
// 从通用传来文本信息 // 从通用传来文本信息
// TODO quary instead of params to fix the bug during refreshing // TODO quary instead of params to fix the bug during refreshing 没办法统一改就task存字段,刷新后去库里找
this.file = JSON.parse(decodeURIComponent(this.$route.params.file)); this.file = JSON.parse(decodeURIComponent(this.$route.params.file));
this.task = JSON.parse(decodeURIComponent(this.$route.params.task)); this.task = JSON.parse(decodeURIComponent(this.$route.params.task));
}, },
methods: { methods: {
// 分出表格
checkTable() {
console.log(this.file.url);
if (
this.file.url
.split("")
.reverse()
.join("")
.substring(0, 4)
.split("")
.reverse()
.join("") == "xlsx"
) {
var params = {
file: encodeURIComponent(JSON.stringify(this.file)),
task: encodeURIComponent(JSON.stringify(this.task))
};
this.$router.push({ name: "table", params });
} else if (
this.file.url
.split("")
.reverse()
.join("")
.substring(0, 3)
.split("")
.reverse()
.join("") == "txt"
) {
this.insertDocument();
}
},
// 插入数据库 // 插入数据库
insertDocument() { insertDocument() {
console.log("userId" + this.$store.state.userInfo.userId); console.log("userId" + this.$store.state.userInfo.userId);
//console.log("file" + JSON.stringify(this.file)); console.log("file" + JSON.stringify(this.file));
//console.log("task" + JSON.stringify(this.task)); console.log("task" + JSON.stringify(this.task));
this.axios({ this.axios({
method: "post", method: "post",
url: "/textAnnotation/insertDocument", url: "/textAnnotation/insertDocument",
...@@ -284,6 +277,23 @@ export default { ...@@ -284,6 +277,23 @@ export default {
res.result.forEach(element => { res.result.forEach(element => {
console.log("this.token: " + element); console.log("this.token: " + element);
this.tokenList.push(element); this.tokenList.push(element);
this.token = element;
let replaceReg = new RegExp(this.token.word, "g"); // 匹配关键字正则
let replaceString =
'<span class="highlights-text">' +
this.token.word +
"</span>" +
'<span class="mark">' +
"(实体:" +
this.token.entityId +
";属性:" +
this.token.attribute +
")" +
"</span>"; // 高亮替换v-html值
if (this.token.entityId == "" && this.token.attribute == []) {
} else {
this.content = this.content.replace(replaceReg, replaceString);
}
}); });
} else { } else {
this.$message({ this.$message({
...@@ -307,7 +317,7 @@ export default { ...@@ -307,7 +317,7 @@ export default {
//console.log(res.result) //console.log(res.result)
// 实体 // 实体
this.token.entityId = JSON.stringify(res.result.templateId); // 现在的实体与模板相近,所以就先固定了 this.token.entityId = JSON.stringify(res.result.templateId); // 现在的实体与模板相近,所以就先固定了
this.options.push(res.result.templateName); this.value = res.result.templateName;
// 属性 // 属性
this.treeData = res.result.entityList; this.treeData = res.result.entityList;
} else { } else {
...@@ -333,7 +343,7 @@ export default { ...@@ -333,7 +343,7 @@ export default {
//console.log("token: " + JSON.stringify(this.token)); //console.log("token: " + JSON.stringify(this.token));
} }
}, },
// 添加标注 // 添加标注 // TODO 大于段落的标注还是无法渲染
handleCheckChange() { handleCheckChange() {
this.ifAlert = false; this.ifAlert = false;
this.token.entityId = this.value; // 实体 this.token.entityId = this.value; // 实体
...@@ -359,15 +369,14 @@ export default { ...@@ -359,15 +369,14 @@ export default {
this.token.attribute + this.token.attribute +
")" + ")" +
"</span>"; // 高亮替换v-html值 "</span>"; // 高亮替换v-html值
if (this.token.entityId == "" && this.token.attribute == []) return;
console.log("文本渲染" + replaceReg + replaceString); console.log("文本渲染" + replaceReg + replaceString);
// TODO length bug
if (this.token.entityId == "" && this.token.attribute.length == 0) return;
// 保存token // 保存token
this.axios({ this.axios({
method: "post", method: "post",
url: "/textAnnotation/addToken", url: "/textAnnotation/addToken",
data: { data: {
documentId: this.file.id, documentId: this.documentId,
token: { token: {
word: this.token.word, word: this.token.word,
begin: this.token.begin, begin: this.token.begin,
...@@ -393,83 +402,51 @@ export default { ...@@ -393,83 +402,51 @@ export default {
}); });
} }
}); });
// 不知道为啥有缓存不能清除 // TODO 不知道为啥有缓存不能清除
// this.$nextTick(() => { // this.$nextTick(() => {
// this.$refs.tree.setCheckedKeys([]); // this.$refs.tree.setCheckedKeys([]);
//}); //});
this.value = "";
return (this.content = this.content.replace(replaceReg, replaceString)); return (this.content = this.content.replace(replaceReg, replaceString));
}, },
// TODO 还没测试 修改实体属性=删除+添加(如果选择属性弹窗没有点提交直接关掉的话会删除)
handleTokenChange(tag) {
this.ifAlert = true;
this.token = tag;
this.tokenList.splice(this.tokenList.indexOf(tag), 1);
this.$options.methods.handleTokenClose(tag);
},
// 直接调用修改接口(因为选择属性弹窗的提交会触发保存标注操作所以会再次产生一个标注,修改也不会成功)
// handleTokenChange(tag) {
// this.ifAlert = true;
// let token = tag;
// this.token = tag;
// tag = {};
// this.axios({
// method: "post",
// url: "http://127.0.0.1:9100/textAnnotation/revToken",
// data: {
// documentId: "a55a28d4a25811ea93c354e1ad87433a",//改成通用跳转传过来的documentId
// token:{
// entityId: this.token.entityId, // 这里类型似乎是string
// word: this.token.word,
// begin: this.token.begin,
// end: this.token.end,
// attribute: arr[0],
// // 修改实体时待改正
// tokenId: this.token.tokenId
// }
// }
// }).then(res => {
// if(res.return_code == 200){
// console.log("123" + res.return_info);
// this.token.attribute = arr[0];
// arr = [];
// this.tokenList.splice(this.tokenList.indexOf(token), 1);
// this.tokenList.push(this.token);
// }
// });
// },
// 删除实体属性 // 删除实体属性
handleTokenClose(tag) { handleTokenClose(tag) {
this.tokenList.splice(this.tokenList.indexOf(tag), 1); this.tokenList.splice(this.tokenList.indexOf(tag), 1);
this.token = tag; this.token = tag;
let replaceReg = new RegExp( var str = '<span class="highlights-text">' + this.token.word + "</span>";
var strIndeed =
'<span class="highlights-text">' + '<span class="highlights-text">' +
this.token.word + this.token.word +
"</span>" + "</span>" +
'<span class="mark">' + '<span class="mark">' +
"(实体:" + "(实体:" +
this.token.entityId + this.token.entityId +
";属性:" + ";属性:" +
this.token.attribute + this.token.attribute +
")" + ")" +
"</span>", "</span>";
"g" console.log(str);
); // 匹配关键字正则 let replaceReg = new RegExp(str, "g"); // 匹配关键字正则
let replaceString = this.token.word; let replaceString = this.token.word;
// TODO 呕呵我傻了,为啥正则匹配不上呢,怪气人的哦
if (this.content.match(replaceReg)) {
console.log("fuck");
} else {
console.log("hello");
console.log("hello");
console.log("hello");
console.log("hello");
console.log("hello");
}
this.content = this.content.replace(replaceReg, replaceString); this.content = this.content.replace(replaceReg, replaceString);
console.log("hello"); //console.log(this.content);
console.log("hello");
console.log("hello");
console.log(this.content);
console.log(replaceReg); console.log(replaceReg);
// TODO length bug console.log(replaceString);
if (this.token.entityId == "" && this.token.attribute == []) return; if (this.token.entityId == "" && this.token.attribute == []) return;
this.axios({ this.axios({
method: "post", method: "post",
url: "/textAnnotation/deleteToken", url: "/textAnnotation/deleteToken",
data: { data: {
documentId: this.file.id, documentId: this.documentId,
tokenId: this.token.tokenId tokenId: this.token.tokenId
} }
}).then(res => { }).then(res => {
...@@ -492,31 +469,61 @@ export default { ...@@ -492,31 +469,61 @@ export default {
//this.value = ""; //this.value = "";
return (this.content = this.content.replace(replaceReg, replaceString)); return (this.content = this.content.replace(replaceReg, replaceString));
}, },
// TODO 还没测试 修改实体属性=删除+添加(如果选择属性弹窗没有点提交直接关掉的话会删除)
// 提交已标注文档 // TODO 跳转到我的任务,已标注文档标注按钮消失,然后判定整个任务都标注完成后跳转到已完成任务界面,这个就交给通用的大佬们了 handleTokenChange(tag) {
submit() { this.ifAlert = true;
// console.log("hello" + JSON.stringify(this.task)) this.token = tag;
this.axios this.$options.methods.handleTokenClose(tag);
.post({ this.tokenList.splice(this.tokenList.indexOf(tag), 1);
method: "post", },
url: "/textAnnotation/revDocumentState", rePage(ins) {
//确定创建模板
if (ins == 1) {
this.axios({
method: "POST",
url: "/textAnnotation/createTemplated",
data: { data: {
documentId: this.documentId templateId: this.options.length + 1,
templateName: this.form.name,
templateType: 0,
creatorId: this.$store.state.userInfo.userId,
entityList: this.entityList
} }
}) }).then(res => {
.then(res => { if (res.code == 1) {
if (res.return_code == 200) { this.options = res.message;
this.$message({
type: "success",
message: "已提交"
});
} else { } else {
this.$message({ alert("模板创建失败");
message: res.return_info,
type: "error"
});
} }
this.dialogFormVisible = false;
}); });
}
// console(this.pOptions);
// // alert("111");
//location.reload();
},
// 提交已标注文档 // TODO 跳转到我的任务,已标注文档标注按钮消失,然后判定整个任务都标注完成后跳转到已完成任务界面,这个就交给通用的大佬们了
submit() {
// console.log("hello" + JSON.stringify(this.task))
this.axios({
method: "post",
url: "/textAnnotation/revDocumentState",
data: {
documentId: this.documentId
}
}).then(res => {
if (res.return_code == 200) {
this.$message({
message: "已保存",
type: "success"
});
} else {
this.$message({
message: res.return_info,
type: "error"
});
}
});
this.$router.replace({ this.$router.replace({
name: "ongoingtaskdetail", name: "ongoingtaskdetail",
params: { task: encodeURIComponent(JSON.stringify(this.task)) } params: { task: encodeURIComponent(JSON.stringify(this.task)) }
...@@ -524,7 +531,7 @@ export default { ...@@ -524,7 +531,7 @@ export default {
} }
}, },
mounted: function() { mounted: function() {
this.checkTable(); this.insertDocument();
} }
}; };
</script> </script>
......
...@@ -50,10 +50,13 @@ ...@@ -50,10 +50,13 @@
<div style="overflow-y:auto;height:100%;"> <div style="overflow-y:auto;height:100%;">
<!-- 表格界面 --> <!-- 表格界面 -->
<div @click="highlight()"> <div @click="highlight()">
<el-table :data="tableData" border style="width: 100%"> <el-table :data="nowContent.tableData" border style="width: 100%,height:200px">
<el-table-column prop="date" label="日期" width="180"></el-table-column> <el-table-column
<el-table-column prop="name" label="姓名" width="180"></el-table-column> v-for="col in nowContent.name"
<el-table-column prop="address" label="地址"></el-table-column> :key="col"
:prop="col.value"
:label="col.value" >
</el-table-column>
</el-table> </el-table>
</div> </div>
<!-- 表格界面 --> <!-- 表格界面 -->
...@@ -133,7 +136,12 @@ export default { ...@@ -133,7 +136,12 @@ export default {
options: [], options: [],
// table // table
tableData: [] nowContent:{
tablename:"",
tableData:[],
name:[]
},
allContent:[]
}; };
}, },
beforeMount() { beforeMount() {
...@@ -177,7 +185,31 @@ export default { ...@@ -177,7 +185,31 @@ export default {
}, },
//获取内容 //获取内容
getContent() { getContent() {
// TODO this.axios({
method: "post",
url: "/files/getExcelContent",
data: {
documentId: this.documentId
}
}).then(res => {
if (res.return_code == 200) {
var i;
var nowContent = {};
for(i = 0;i<res.result.numOfSheet;i++){
nowContent.tablename = res.result.content[i].sheetName;
nowContent.tableData = res.result.content[i].content;
nowContent.name = res.result.content[i].name;
this.allContent.push(nowContent);
nowContent = {};
}
this.nowContent = this.allContent[0];//默认打开第一个
} else {
this.$message({
message: res.return_info,
type: "error"
});
}
});
}, },
// 获得实体属性列表 // 获得实体属性列表
getTokenList() { getTokenList() {
...@@ -388,30 +420,28 @@ export default { ...@@ -388,30 +420,28 @@ export default {
return (this.content = this.content.replace(replaceReg, replaceString)); return (this.content = this.content.replace(replaceReg, replaceString));
}, },
// 提交已标注文档 // 提交已标注文档 // TODO 跳转到我的任务,已标注文档标注按钮消失,然后判定整个任务都标注完成后跳转到已完成任务界面,这个就交给通用的大佬们了
submit() { submit() {
// console.log("hello" + JSON.stringify(this.task)) // console.log("hello" + JSON.stringify(this.task))
this.axios this.axios({
.post({ method: "post",
method: "post", url: "/textAnnotation/revDocumentState",
url: "/textAnnotation/revDocumentState", data: {
data: { documentId: this.documentId
documentId: this.documentId }
} }).then(res => {
}) if (res.return_code == 200) {
.then(res => { this.$message({
if (res.return_code == 200) { message: "已保存",
this.$message({ type: "success"
type: "success", });
message: "已提交" } else {
}); this.$message({
} else { message: res.return_info,
this.$message({ type: "error"
message: res.return_info, });
type: "error" }
}); });
}
});
this.$router.replace({ this.$router.replace({
name: "ongoingtaskdetail", name: "ongoingtaskdetail",
params: { task: encodeURIComponent(JSON.stringify(this.task)) } params: { task: encodeURIComponent(JSON.stringify(this.task)) }
......
home = C:\Users\ljxfai\AppData\Local\Programs\Python\Python37 home = D:\Python\Python37
include-system-site-packages = false include-system-site-packages = false
version = 3.7.3 version = 3.7.3
...@@ -212,7 +212,6 @@ def insertDocument(): ...@@ -212,7 +212,6 @@ def insertDocument():
# 修改标注状态 # 修改标注状态
# 插入document
@textAnnotation.route("/revDocumentState", methods=["POST"]) @textAnnotation.route("/revDocumentState", methods=["POST"])
def revDocumentState(): def revDocumentState():
# 默认返回内容 # 默认返回内容
......
...@@ -165,8 +165,22 @@ def getExcelContent(): ...@@ -165,8 +165,22 @@ def getExcelContent():
cols = workbook.sheet_by_index(sheet).ncols cols = workbook.sheet_by_index(sheet).ncols
d1.update({"numOfRow": rows}) d1.update({"numOfRow": rows})
d1.update({"numOfCol": cols}) d1.update({"numOfCol": cols})
d2 = [] name = []
for col in range(cols):
ctype = workbook.sheet_by_index(sheet).cell(0, col).ctype
cell = workbook.sheet_by_index(sheet).cell_value(0, col)
if ctype == 2 and cell % 1 == 0.0:
cell = int(cell)
cell = str(cell)
elif ctype == 3:
date = datetime(*xldate_as_tuple(cell, 0))
cell = date.strftime('%Y/%m/%d %H:%M:%S')
name.append({"value": cell})
d2 = {}
d3 = []
for row in range(rows): for row in range(rows):
if row == 0:
continue
for col in range(cols): for col in range(cols):
ctype = workbook.sheet_by_index(sheet).cell(row, col).ctype ctype = workbook.sheet_by_index(sheet).cell(row, col).ctype
cell = workbook.sheet_by_index(sheet).cell_value(row, col) cell = workbook.sheet_by_index(sheet).cell_value(row, col)
...@@ -176,8 +190,11 @@ def getExcelContent(): ...@@ -176,8 +190,11 @@ def getExcelContent():
elif ctype == 3: elif ctype == 3:
date = datetime(*xldate_as_tuple(cell, 0)) date = datetime(*xldate_as_tuple(cell, 0))
cell = date.strftime('%Y/%m/%d %H:%M:%S') cell = date.strftime('%Y/%m/%d %H:%M:%S')
d2.append({"value": cell}) d2.update({name[col].get("value"): cell})
d1.update({"content": d2}) d3.append(d2)
d2 = {}
d1.update({"name": name})
d1.update({"content": d3})
statement.append(d1) statement.append(d1)
data.update({"content": statement}) data.update({"content": statement})
return_dict["result"] = data return_dict["result"] = data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment