|
@@ -0,0 +1,185 @@
|
|
|
+<template>
|
|
|
+ <div v-loading="isLoading">
|
|
|
+ <el-dialog :title="isEdit?`编辑[${rawData.itemName}]信息`:`新增子项`" top="0" :close-on-click-modal="false" :visible.sync="showThisDialog" >
|
|
|
+ <div class="line">
|
|
|
+ <div class="label">
|
|
|
+ {{arithmetic === aiTypes.face? "员工姓名":"车辆名称"}}
|
|
|
+ </div>
|
|
|
+ <div class="input">
|
|
|
+ <el-input v-model="itemName"></el-input>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="line img-line" v-if="arithmetic === aiTypes.face">
|
|
|
+ <div class="label">
|
|
|
+ 员工照片
|
|
|
+ </div>
|
|
|
+ <div class="input">
|
|
|
+ <div class="" style="width: 100px;height: 100px">
|
|
|
+ <s-img :raw-image="'/aiLib/libImg/'+rawData.imageUrl"
|
|
|
+ @imgChange="imgChangeHandle"
|
|
|
+ ></s-img>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="line">
|
|
|
+ <div class="label">
|
|
|
+ {{arithmetic === aiTypes.face? "员工工号":"车牌号"}}
|
|
|
+ </div>
|
|
|
+ <div class="input">
|
|
|
+ <el-input v-model="itemNo"></el-input>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="line">
|
|
|
+ <div class="label">
|
|
|
+ {{arithmetic === aiTypes.face? "身份证":"车牌号"}}
|
|
|
+ </div>
|
|
|
+ <div class="input">
|
|
|
+ <el-input v-if="arithmetic === aiTypes.face" v-model="idCard"></el-input>
|
|
|
+ <el-input v-if="arithmetic === aiTypes.carPlate" v-model="carNo"></el-input>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <el-divider></el-divider>
|
|
|
+ <el-button-group>
|
|
|
+ <el-button @click="resetData" type="danger">重置</el-button>
|
|
|
+ <el-button v-if="!isEdit" type="primary" @click="addHandle">添加数据</el-button>
|
|
|
+ <el-button v-else-if="isEdit" type="primary" @click="editHandle">编辑数据</el-button>
|
|
|
+ </el-button-group>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import aiMap from "@/map/ai"
|
|
|
+import handle from "@/until/handle";
|
|
|
+import SImg from "@/components/common/SImg";
|
|
|
+export default {
|
|
|
+ name: "editLibItem",
|
|
|
+ components: {SImg},
|
|
|
+ data(){
|
|
|
+ return {
|
|
|
+ aiTypes: aiMap.aiTypes,
|
|
|
+ isLoading:false,
|
|
|
+ showThisDialog:false,
|
|
|
+ arithmetic: 0,
|
|
|
+ isEdit: false,
|
|
|
+ rawData: {},
|
|
|
+ itemId: '',
|
|
|
+ itemName: '',
|
|
|
+ itemNo: '',
|
|
|
+ itemType: '',
|
|
|
+ trait: '',
|
|
|
+ imageUrl: '',
|
|
|
+ carNo: '',
|
|
|
+ idCard: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods:{
|
|
|
+ init(){
|
|
|
+ this.arithmetic = 0;
|
|
|
+ this.itemName= '';
|
|
|
+ },
|
|
|
+ async openEditDialog(libraryId,arithmetic,itemId){
|
|
|
+ this.isEdit = true;
|
|
|
+ this.libraryId = libraryId;
|
|
|
+ this.arithmetic = arithmetic;
|
|
|
+ this.itemId = itemId;
|
|
|
+ await this.loadLibItemData();
|
|
|
+ this.showDialog();
|
|
|
+ },
|
|
|
+ openAddDialog(libraryId,arithmetic){
|
|
|
+ this.libraryId = libraryId;
|
|
|
+ this.arithmetic = arithmetic;
|
|
|
+ this.isEdit = false;
|
|
|
+ this.showDialog();
|
|
|
+ },
|
|
|
+ showDialog(){
|
|
|
+ this.showThisDialog = true;
|
|
|
+ },
|
|
|
+ resetData(){
|
|
|
+ this.itemName = this.rawData.itemName;
|
|
|
+ this.imageUrl = "";
|
|
|
+ this.uploadFile = null;
|
|
|
+ this.itemNo = this.rawData.itemNo;
|
|
|
+ this.itemType = this.rawData.itemType;
|
|
|
+ this.trait = this.rawData.trait;
|
|
|
+ this.carNo = this.rawData.carNo;
|
|
|
+ },
|
|
|
+ async loadLibItemData(){
|
|
|
+ this.isLoading = true;
|
|
|
+ let url = `/api/device/query/itemInfo/${this.itemId}`
|
|
|
+ let [err,res] = await handle(this.$axios(
|
|
|
+ {
|
|
|
+ method: 'get',
|
|
|
+ url: url
|
|
|
+ }
|
|
|
+ ));
|
|
|
+ this.isLoading = false;
|
|
|
+ if(err){
|
|
|
+ console.error(err);
|
|
|
+ console.error(res);
|
|
|
+ this.$message.error(err.message);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log('------------');
|
|
|
+ console.log(res)
|
|
|
+ let result = res.data;
|
|
|
+ if(res.data.code === 0){
|
|
|
+ this.rawData = result.data;
|
|
|
+ this.resetData();
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ imgChangeHandle(file){
|
|
|
+ if(file){
|
|
|
+ console.log('修改图片')
|
|
|
+ this.uploadFile = file;
|
|
|
+ console.log(file);
|
|
|
+ }else{
|
|
|
+ console.log('不修改图片')
|
|
|
+ this.imageUrl = "";
|
|
|
+ this.uploadFile = null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ addHandle(){
|
|
|
+
|
|
|
+ },
|
|
|
+ editHandle(){
|
|
|
+ // 获取编辑项
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.line{
|
|
|
+ width: 100%;
|
|
|
+ height: 35px;
|
|
|
+ display: flex;
|
|
|
+ margin-bottom: 10px;
|
|
|
+
|
|
|
+}
|
|
|
+.img-line{
|
|
|
+ height: 120px;
|
|
|
+}
|
|
|
+.line .label{
|
|
|
+ width: 20%;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+.line .input{
|
|
|
+ width: 80%;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding-left: 8px;
|
|
|
+ border-left: 1px solid grey;
|
|
|
+}
|
|
|
+</style>
|