Commit e4fed9fa authored by renjintao's avatar renjintao

importimport

parent c511ba38
This diff is collapsed.
<template> <template>
<Form ref="form" :model="entity" :rules="rules" :label-width="90"> <Form ref="form" :model="entity" :rules="rules" :label-width="90">
<Row> <Row>
<Col :span="12"> <Col :span="12">
<FormItem :label="l('name')" prop="name"> <FormItem :label="l('name')" prop="name">
<Input v-model="entity.name"></Input> <Input v-model="entity.name"></Input>
</FormItem> </FormItem>
</Col> </Col>
<Col :span="24"> <Col :span="24">
<FormItem :label="l('file')" prop="file"> <FormItem :label="l('file')" prop="file">
<InputExcel v-model="imgName" :parms="parms" :showButton="false" /> <InputExcel v-model="imgName" :parms="parms" :showButton="false" />
</FormItem> </FormItem>
</Col> </Col>
<Col :span="24"> <Col :span="24">
<FormItem :label="l('remark')" prop="remark"> <FormItem :label="l('remark')" prop="remark">
<Input v-model="entity.remark" type="textarea" :rows="5"></Input> <Input v-model="entity.remark" type="textarea" :rows="5"></Input>
</FormItem> </FormItem>
</Col> </Col>
</Row> </Row>
<FormItem> <FormItem>
<Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button> <Button type="primary" @click="handleSubmit" :disabled="disabled">保存</Button>
<Button @click="handleClose" class="ml20">取消</Button> <Button @click="handleClose" class="ml20">取消</Button>
</FormItem> </FormItem>
</Form> </Form>
</template> </template>
<script>
<script>
import Api from "./api"; import Api from "./api";
import InputExcel from "@/components/page/inputExcel.vue"; import InputExcel from "@/components/page/inputExcel.vue";
export default { export default {
name: "Add", name: "Add",
components: { components: {
InputExcel InputExcel
},
data() {
return {
disabled: false,
parms: "app=import&eid="+this.$u.guid()+"&name=excel",
imgName: "",
entity: {
name: "",
file: "",
filePath:"",
remark: "",
},
rules: {
name: [{ required: true, message: "必填", trigger: "blur" }],
file:[{ required: true, message: "请上传文件", trigger: "change" }]
},
};
},
props: {
v: Object,
eid: Number,
},
mounted() {
if (this.eid > 0) {
this.load(this.eid);
}
},
methods: {
handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
this.disabled = true;
Api.create(this.entity)
.then((r) => {
this.disabled = false;
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.disabled = false;
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.$emit("on-close");
},
load(v) {
Api.get({ id: v }).then((r) => {
this.entity = r.result;
this.entity.id = 0;
});
}, },
getEid() { data() {
this.parms.eid = this.$u.guid() return {
this.parms.app = 'import' disabled: false,
this.$refs.refFile.intFiles() parms: "app=import&eid=" + this.$u.guid() + "&name=excel",
imgName: "",
entity: {
name: "",
file: "",
path: "",
remark: "",
},
rules: {
name: [{
required: true,
message: "必填",
trigger: "blur"
}],
file: [{
required: true,
message: "请上传文件",
trigger: "change"
}]
},
};
}, },
l(key) { props: {
key = "import_center" + "." + key; v: Object,
return this.$t(key); eid: Number,
}, },
}, mounted() {
watch: { if (this.eid > 0) {
imgName(newName, oldName) { this.load(this.eid);
const imgPathsArr = JSON.parse(newName); }
this.entity.file=imgPathsArr[0].fileName
this.entity.filePath=imgPathsArr[0].filePath
}, },
v() { methods: {
this.entity = this.$u.clone(this.v); handleSubmit() {
this.$refs.form.validate((v) => {
if (v) {
this.disabled = true;
Api.create(this.entity)
.then((r) => {
this.disabled = false;
if (r.success) {
this.$Message.success("保存成功");
this.$emit("on-ok");
} else {
this.$Message.error("保存失败");
}
})
.catch((err) => {
this.disabled = false;
this.$Message.error("保存失败");
console.warn(err);
});
}
});
},
handleClose() {
this.$emit("on-close");
},
load(v) {
Api.get({
id: v
}).then((r) => {
this.entity = r.result;
this.entity.id = 0;
});
},
getEid() {
this.parms.eid = this.$u.guid()
this.parms.app = 'import'
this.$refs.refFile.intFiles()
},
l(key) {
key = "import_center" + "." + key;
return this.$t(key);
},
}, },
eid(v) { watch: {
if (v > 0) { imgName(newName, oldName) {
this.load(v); const imgPathsArr = JSON.parse(newName);
} this.entity.file = imgPathsArr[0].fileName
this.entity.path = imgPathsArr[0].filePath
},
v() {
this.entity = this.$u.clone(this.v);
},
eid(v) {
if (v > 0) {
this.load(v);
}
},
}, },
},
}; };
</script> </script>
...@@ -24,5 +24,8 @@ export default { ...@@ -24,5 +24,8 @@ export default {
deletes(params) { deletes(params) {
return Api.post(`${systemUrl}/importcenter/batchdelete`, params); return Api.post(`${systemUrl}/importcenter/batchdelete`, params);
}, },
openExcel(params) {//处理时打开以前上传的excel返回数据
return Api.post(`${systemUrl}/importcenter/open`, params);
},
} }
<template> <template>
<div class="detail"> <div class="detail">
<Row> <Row>
<Filed :span="12" :name="l('name')">{{entity.name}}</Filed>
<Filed :span="12" :name="l('name')">{{entity.name}}</Filed> <Filed :span="12" :name="l('file')">
<Filed :span="12" :name="l('file')"><a @click="downFile(entity.filePath)">{{entity.file}}</a></Filed> <a @click="downFile(entity.path)">{{entity.file}}</a>
<Filed :span="12" :name="l('status')">{{entity.status}}</Filed> </Filed>
<Filed :span="24" :name="l('remark')">{{entity.remark}}</Filed> <Filed :span="12" :name="l('status')">
<Filed :span="12" :name="l('creationTime')">{{entity.creationTime}}</Filed> <state code="improt.im.status" :value="entity.status" type="text"></state>
<Filed :span="12" :name="l('creatorUserId')">{{entity.creatorUserId}}</Filed> </Filed>
<Filed :span="12" :name="l('lastModificationTime')">{{entity.lastModificationTime}}</Filed> <Filed :span="24" :name="l('remark')">{{entity.remark}}</Filed>
<Filed :span="12" :name="l('lastModifierUserId')">{{entity.lastModifierUserId}}</Filed> <Filed :span="12" :name="l('creationTime')">{{entity.creationTime}}</Filed>
<Filed :span="12" :name="l('isDeleted')">{{entity.isDeleted}}</Filed> <Filed :span="12" :name="l('creatorUserId')">
<Filed :span="12" :name="l('deletionTime')">{{entity.deletionTime}}</Filed> <User :value="entity.creatorUserId"></User>
<Filed :span="12" :name="l('deleterUserId')">{{entity.deleterUserId}}</Filed> </Filed>
<Filed :span="12" :name="l('creator')">{{entity.creator}}</Filed> <!--
<Filed :span="12" :name="l('lastModifier')">{{entity.lastModifier}}</Filed> <Filed :span="12" :name="l('lastModificationTime')">{{entity.lastModificationTime}}</Filed>
<Filed :span="12" :name="l('lastModifierUserId')">
{{entity.lastModifierUserId}}
<User :value="entity.lastModifierUserId"></User>
</Filed>
<Filed :span="12" :name="l('isDeleted')">{{entity.isDeleted}}</Filed>
<Filed :span="12" :name="l('deletionTime')">{{entity.deletionTime}}</Filed>
<Filed :span="12" :name="l('deleterUserId')">
{{entity.deleterUserId}}
<User :value="entity.deleterUserId"></User>
</Filed>
<Filed :span="12" :name="l('creator')">{{entity.creator}}</Filed>
<Filed :span="12" :name="l('lastModifier')">{{entity.lastModifier}}</Filed>
-->
</Row> </Row>
</div> </div>
</template> </template>
<script> <script>
import Api from "./api"; import Api from "./api";
export default { export default {
name: "Add", name: "Add",
data() { data() {
return { return {
entity: {}, entity: {},
downUrl: fileUrlDown, downUrl: fileUrlDown,
fileUrlPath: "", fileUrlPath: "",
rules: { rules: {
name: [{ required: true, message: "必填", trigger: "blur" }], name: [{
code: [{ required: true, message: "必填", trigger: "blur" }], required: true,
}, message: "必填",
}; trigger: "blur",
}, }, ],
props: { code: [{
eid: Number, required: true,
}, message: "必填",
mounted() { trigger: "blur",
if (this.eid > 0) { }, ],
this.load(this.eid); },
} };
},
methods: {
load(v) {
Api.get({ id: v }).then((r) => {
this.entity = r.result;
this.$emit("on-load");
});
}, },
handleClose() { props: {
this.$emit("on-close"); eid: Number,
}, },
downFile(path) { mounted() {
alert(path) if (this.eid > 0) {
let truePath = path.trim(); this.load(this.eid);
if (truePath.length > 2) {
if (
truePath.substring(0, 7).toLowerCase() == "http://" ||
truePath.substring(0, 8).toLowerCase() == "https://"
) {
window.open(truePath, "_blank");
} else {
this.fileUrlPath = this.downUrl + path;
window.open(this.fileUrlPath, "_blank");
} }
}
}, },
l(key) { methods: {
key = "import_center" + "." + key; load(v) {
return this.$t(key); Api.get({
id: v,
}).then((r) => {
this.entity = r.result;
this.$emit("on-load");
});
},
handleClose() {
this.$emit("on-close");
},
downFile(path) {
//alert(path)
let truePath = path;
if (truePath.length > 2) {
if (
truePath.substring(0, 7).toLowerCase() == "http://" ||
truePath.substring(0, 8).toLowerCase() == "https://"
) {
window.open(truePath, "_blank");
} else {
this.fileUrlPath = this.downUrl + path;
window.open(this.fileUrlPath, "_blank");
}
}
},
l(key) {
key = "import_center" + "." + key;
return this.$t(key);
},
}, },
}, watch: {
watch: { eid(v) {
eid(v) { if (v > 0) {
if (v > 0) { this.load(v);
this.load(v); }
} },
}, },
},
}; };
</script> </script>
This diff is collapsed.
This diff is collapsed.
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