文档服务地址: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 @@
</template>
<script>
import PiecesTable from './PiecesTable'
import PiecesTable from "./PiecesTable"
export default {
name: 'on-going-task-detail',
name: "on-going-task-detail",
components: {
PiecesTable
},
data () {
data() {
return {
task: null
}
};
},
beforeMount () {
beforeMount() {
this.task = JSON.parse(decodeURIComponent(this.$route.params.task))
},
methods: {
doOption (file, type) {
//console.log("this.task"+JSON.stringify(this.task));
//console.log("this.file"+JSON.stringify(file));
var params = { file: encodeURIComponent(JSON.stringify(file)), task: encodeURIComponent(JSON.stringify(this.task)) }
var self = this
function goto (path) {
doOption(file, type) {
var params = {
file: encodeURIComponent(JSON.stringify(file)),
task: encodeURIComponent(JSON.stringify(this.task))
};
var self = this;
function goto(path) {
self.$router.push({ name: path, params })
}
switch (type) {
case '文本': goto('SelectText'); break
case '图片': goto('image'); break
case '图层': goto('layer'); break
case '表格': goto('table')
case "文本":
if (
file.url
.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>
<style lang="scss" scoped>
......
......@@ -59,15 +59,28 @@
<!-- 弹窗-->
<el-dialog title="请标注" :visible.sync="ifAlert">
<div style="overflow: auto;height: 50vh">
<el-select v-model="value" placeholder="选择标注对象">
<!-- 实体 -->
<!-- <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-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-button type="primary" @click="handleOption">新建</el-button-->
<!-- 属性 -->
<el-tree
:data="treeData"
show-checkbox
......@@ -82,6 +95,36 @@
<el-button type="primary" style="margin-top: 30px" @click="handleCheckChange">确定</el-button>
</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>
</el-main>
</el-container>
......@@ -113,36 +156,6 @@ export default {
// 文章列表
textData: [],
// templete
// treeDataExample: [
// {
// label: "宏观稳定性",
// children: [
// {
// label: "不稳定"
// },
// {
// label: "基本稳定"
// },
// {
// label: "稳定"
// }
// ]
// },
// {
// label: "确定性程度",
// children: [
// {
// label: "确定"
// },
// {
// label: "基本确定"
// },
// {
// label: "不确定"
// }
// ]
// }
// ],
treeData: [],
defaultProps: {
......@@ -153,72 +166,52 @@ export default {
ifAlert: false, // 弹窗
// 实体
value: "",
// optionsExample: [
// {
// value: "选项1",
// label: "滑坡"
// },
// {
// value: "选项2",
// label: "山体"
// },
// {
// value: "选项3",
// label: "河流"
// },
// {
// value: "选项4",
// label: "时间"
// }
// ],
options: [],
options: [
{
value: "选项1",
label: "滑坡"
},
{
value: "选项2",
label: "山体"
},
{
value: "选项3",
label: "河流"
},
{
value: "选项4",
label: "时间"
}
],
// 弹窗
dialogFormVisible: false,
form: {
name: "",
region: "",
date1: "",
date2: "",
delivery: false,
type: [],
resource: "",
desc: ""
},
// table
tableData: []
};
},
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.task = JSON.parse(decodeURIComponent(this.$route.params.task));
},
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() {
console.log("userId" + this.$store.state.userInfo.userId);
//console.log("file" + JSON.stringify(this.file));
//console.log("task" + JSON.stringify(this.task));
console.log("file" + JSON.stringify(this.file));
console.log("task" + JSON.stringify(this.task));
this.axios({
method: "post",
url: "/textAnnotation/insertDocument",
......@@ -284,6 +277,23 @@ export default {
res.result.forEach(element => {
console.log("this.token: " + 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 {
this.$message({
......@@ -307,7 +317,7 @@ export default {
//console.log(res.result)
// 实体
this.token.entityId = JSON.stringify(res.result.templateId); // 现在的实体与模板相近,所以就先固定了
this.options.push(res.result.templateName);
this.value = res.result.templateName;
// 属性
this.treeData = res.result.entityList;
} else {
......@@ -333,7 +343,7 @@ export default {
//console.log("token: " + JSON.stringify(this.token));
}
},
// 添加标注
// 添加标注 // TODO 大于段落的标注还是无法渲染
handleCheckChange() {
this.ifAlert = false;
this.token.entityId = this.value; // 实体
......@@ -359,15 +369,14 @@ export default {
this.token.attribute +
")" +
"</span>"; // 高亮替换v-html值
if (this.token.entityId == "" && this.token.attribute == []) return;
console.log("文本渲染" + replaceReg + replaceString);
// TODO length bug
if (this.token.entityId == "" && this.token.attribute.length == 0) return;
// 保存token
this.axios({
method: "post",
url: "/textAnnotation/addToken",
data: {
documentId: this.file.id,
documentId: this.documentId,
token: {
word: this.token.word,
begin: this.token.begin,
......@@ -393,57 +402,18 @@ export default {
});
}
});
// 不知道为啥有缓存不能清除
// TODO 不知道为啥有缓存不能清除
// this.$nextTick(() => {
// this.$refs.tree.setCheckedKeys([]);
//});
this.value = "";
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) {
this.tokenList.splice(this.tokenList.indexOf(tag), 1);
this.token = tag;
let replaceReg = new RegExp(
var str = '<span class="highlights-text">' + this.token.word + "</span>";
var strIndeed =
'<span class="highlights-text">' +
this.token.word +
"</span>" +
......@@ -453,23 +423,30 @@ export default {
";属性:" +
this.token.attribute +
")" +
"</span>",
"g"
); // 匹配关键字正则
"</span>";
console.log(str);
let replaceReg = new RegExp(str, "g"); // 匹配关键字正则
let replaceString = this.token.word;
this.content = this.content.replace(replaceReg, replaceString);
// 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");
console.log(this.content);
}
this.content = this.content.replace(replaceReg, replaceString);
//console.log(this.content);
console.log(replaceReg);
// TODO length bug
console.log(replaceString);
if (this.token.entityId == "" && this.token.attribute == []) return;
this.axios({
method: "post",
url: "/textAnnotation/deleteToken",
data: {
documentId: this.file.id,
documentId: this.documentId,
tokenId: this.token.tokenId
}
}).then(res => {
......@@ -492,23 +469,53 @@ export default {
//this.value = "";
return (this.content = this.content.replace(replaceReg, replaceString));
},
// TODO 还没测试 修改实体属性=删除+添加(如果选择属性弹窗没有点提交直接关掉的话会删除)
handleTokenChange(tag) {
this.ifAlert = true;
this.token = tag;
this.$options.methods.handleTokenClose(tag);
this.tokenList.splice(this.tokenList.indexOf(tag), 1);
},
rePage(ins) {
//确定创建模板
if (ins == 1) {
this.axios({
method: "POST",
url: "/textAnnotation/createTemplated",
data: {
templateId: this.options.length + 1,
templateName: this.form.name,
templateType: 0,
creatorId: this.$store.state.userInfo.userId,
entityList: this.entityList
}
}).then(res => {
if (res.code == 1) {
this.options = res.message;
} else {
alert("模板创建失败");
}
this.dialogFormVisible = false;
});
}
// console(this.pOptions);
// // alert("111");
//location.reload();
},
// 提交已标注文档 // TODO 跳转到我的任务,已标注文档标注按钮消失,然后判定整个任务都标注完成后跳转到已完成任务界面,这个就交给通用的大佬们了
submit() {
// console.log("hello" + JSON.stringify(this.task))
this.axios
.post({
this.axios({
method: "post",
url: "/textAnnotation/revDocumentState",
data: {
documentId: this.documentId
}
})
.then(res => {
}).then(res => {
if (res.return_code == 200) {
this.$message({
type: "success",
message: "已提交"
message: "已保存",
type: "success"
});
} else {
this.$message({
......@@ -524,7 +531,7 @@ export default {
}
},
mounted: function() {
this.checkTable();
this.insertDocument();
}
};
</script>
......
......@@ -50,10 +50,13 @@
<div style="overflow-y:auto;height:100%;">
<!-- 表格界面 -->
<div @click="highlight()">
<el-table :data="tableData" border style="width: 100%">
<el-table-column prop="date" label="日期" width="180"></el-table-column>
<el-table-column prop="name" label="姓名" width="180"></el-table-column>
<el-table-column prop="address" label="地址"></el-table-column>
<el-table :data="nowContent.tableData" border style="width: 100%,height:200px">
<el-table-column
v-for="col in nowContent.name"
:key="col"
:prop="col.value"
:label="col.value" >
</el-table-column>
</el-table>
</div>
<!-- 表格界面 -->
......@@ -133,7 +136,12 @@ export default {
options: [],
// table
tableData: []
nowContent:{
tablename:"",
tableData:[],
name:[]
},
allContent:[]
};
},
beforeMount() {
......@@ -177,7 +185,31 @@ export default {
},
//获取内容
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() {
......@@ -388,22 +420,20 @@ export default {
return (this.content = this.content.replace(replaceReg, replaceString));
},
// 提交已标注文档
// 提交已标注文档 // TODO 跳转到我的任务,已标注文档标注按钮消失,然后判定整个任务都标注完成后跳转到已完成任务界面,这个就交给通用的大佬们了
submit() {
// console.log("hello" + JSON.stringify(this.task))
this.axios
.post({
this.axios({
method: "post",
url: "/textAnnotation/revDocumentState",
data: {
documentId: this.documentId
}
})
.then(res => {
}).then(res => {
if (res.return_code == 200) {
this.$message({
type: "success",
message: "已提交"
message: "已保存",
type: "success"
});
} else {
this.$message({
......
home = C:\Users\ljxfai\AppData\Local\Programs\Python\Python37
home = D:\Python\Python37
include-system-site-packages = false
version = 3.7.3
......@@ -212,7 +212,6 @@ def insertDocument():
# 修改标注状态
# 插入document
@textAnnotation.route("/revDocumentState", methods=["POST"])
def revDocumentState():
# 默认返回内容
......
......@@ -165,8 +165,22 @@ def getExcelContent():
cols = workbook.sheet_by_index(sheet).ncols
d1.update({"numOfRow": rows})
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):
if row == 0:
continue
for col in range(cols):
ctype = workbook.sheet_by_index(sheet).cell(row, col).ctype
cell = workbook.sheet_by_index(sheet).cell_value(row, col)
......@@ -176,8 +190,11 @@ def getExcelContent():
elif ctype == 3:
date = datetime(*xldate_as_tuple(cell, 0))
cell = date.strftime('%Y/%m/%d %H:%M:%S')
d2.append({"value": cell})
d1.update({"content": d2})
d2.update({name[col].get("value"): cell})
d3.append(d2)
d2 = {}
d1.update({"name": name})
d1.update({"content": d3})
statement.append(d1)
data.update({"content": statement})
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