¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <el-dialog :title="titleMap[mode]" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')"> |
| | | <el-form :model="form" :rules="rules" :disabled="mode=='show'" ref="dialogForm" label-width="120px" label-position="center"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="ä¾åºåç¼å·"> |
| | | <el-input placeholder="ä¿åæ¶ç³»ç»èªå¨çæ" disabled clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="ä¾åºååç§°" prop="name"> |
| | | <el-input v-model="form.name" clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="ä¾åºåå°å"> |
| | | <el-input v-model="form.address" clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="èç³»æ¹å¼" prop="tel"> |
| | | <el-input v-model="form.tel" clearable></el-input> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | <template #footer> |
| | | <el-button @click="visible=false" >å æ¶</el-button> |
| | | <el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit">ä¿ å</el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | emits: ['success', 'closed'], |
| | | data() { |
| | | var checkTel = (rule, value, callback) => { |
| | | var reg = /^1[0-9]{10}$/g; |
| | | if(value != "") { |
| | | if (!reg.test(value)) { |
| | | return callback(new Error('请è¾å
¥11使æºå·ç ')); |
| | | } |
| | | } |
| | | callback(); |
| | | }; |
| | | return { |
| | | mode: "add", |
| | | titleMap: { |
| | | add: 'æ°å»ºä¾åºå', |
| | | edit: 'ç¼è¾ä¾åºå', |
| | | show: 'æ¥ç' |
| | | }, |
| | | visible: false, |
| | | isSaveing: false, |
| | | //è¡¨åæ°æ® |
| | | form: { |
| | | name: "", |
| | | address: "", |
| | | tel: "" |
| | | }, |
| | | //éªè¯è§å |
| | | rules: { |
| | | name:[{required: true, message: '请è¾å
¥ä¾åºååç§°'}], |
| | | tel: [{required: true,validator: checkTel, trigger: 'blur'}] |
| | | }, |
| | | } |
| | | }, |
| | | mounted() { |
| | | |
| | | }, |
| | | methods: { |
| | | //æ¾ç¤º |
| | | open(mode='add'){ |
| | | this.mode = mode; |
| | | this.visible = true; |
| | | return this |
| | | }, |
| | | //表åæäº¤æ¹æ³ |
| | | submit(){ |
| | | var obj = Object.assign({},this.form); |
| | | if(this.mode == 'edit') { |
| | | obj.isEdit = true; |
| | | } |
| | | this.$refs.dialogForm.validate(async (valid) => { |
| | | if (valid) { |
| | | this.isSaveing = true; |
| | | this.$HTTP.post("/api/blade-cps/supplier/save",obj).then(res=> { |
| | | this.isSaveing = false; |
| | | if(res.code == 200) { |
| | | this.$emit('success', this.form, this.mode); |
| | | this.visible = false; |
| | | this.$message.success("æä½æå"); |
| | | }else { |
| | | this.$alert(res.message, "æç¤º", {type: 'error'}); |
| | | } |
| | | }) |
| | | }else{ |
| | | return false; |
| | | } |
| | | }) |
| | | }, |
| | | //è¡¨åæ³¨å
¥æ°æ® |
| | | setData(data){ |
| | | //å¯ä»¥åä¸é¢ä¸æ ·å个注å
¥ï¼ä¹å¯ä»¥åä¸é¢ä¸æ ·ç´æ¥åå¹¶è¿å» |
| | | console.log(data,222) |
| | | Object.assign(this.form, data) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- |
| | | * @Author: lzhe lzhe@example.com |
| | | * @Date: 2024-03-26 10:28:33 |
| | | * @LastEditors: lzhe lzhe@example.com |
| | | * @LastEditTime: 2024-06-05 17:06:58 |
| | | * @FilePath: /smart-web/src/views/master/person/main/index.vue |
| | | * @Description: è¿æ¯é»è®¤è®¾ç½®,请设置`customMade`, æå¼koroFileHeaderæ¥çé
ç½® è¿è¡è®¾ç½®: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |
| | | --> |
| | | <template> |
| | | <div class="main"> |
| | | <div class="noData" v-if="latticeList.length == 0"> |
| | | <div style="margin-bottom: 12px;">ææ æ°æ®</div> |
| | | <el-button type="primary" @click="table_create">æ°å»º</el-button> |
| | | </div> |
| | | <div v-if="latticeList.length != 0"> |
| | | <!-- ä¸ä¸ªæ ¼å --> |
| | | <el-button type="primary" @click="create_list" style="margin-bottom: 12px;">æ°å»º</el-button> |
| | | <div v-for="(item,index) in latticeList"> |
| | | <!-- æ°å¢çå¼ --> |
| | | <div v-if="item.status != 1"> |
| | | <el-input v-model="item.name" clearable style="width: 200px;" placeholder="请è¾å
¥å
容"></el-input> |
| | | <span class="add-sure" @click="addLattice(index)">ç¡®å®</span> |
| | | <span class="cencel" @click="cencelLattice(index)">åæ¶</span> |
| | | </div> |
| | | <!-- åæ¾çå¼ --> |
| | | <div v-if="item.status == 1"> |
| | | <span class="title">{{item.name}}</span> |
| | | <span class="edit" @click="editData(index)"><el-icon><EditPen /></el-icon>ç¼è¾</span> |
| | | <span class="delData" @click="delData(index)">å é¤</span> |
| | | </div> |
| | | <div class="upload"> |
| | | <div v-for="(item1,index1) in item.ImageUrlList"> |
| | | <img :src="item1.url" alt="" @click="viewUrl(item1)"> |
| | | </div> |
| | | <el-upload |
| | | :disabled="!item.id" |
| | | :action="action" |
| | | list-type="picture-card" |
| | | :on-success="(file)=>handleAvatarSuccess(file,index)" |
| | | :before-upload="(file)=>beforeAvatarUpload(file,index)"> |
| | | <el-icon><Plus /></el-icon> |
| | | </el-upload> |
| | | <el-dialog :visible.sync="dialogVisible"> |
| | | <img width="100%" :src="dialogImageUrl" alt=""> |
| | | </el-dialog> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import * as ElementPlusIconsVue from '@element-plus/icons-vue' |
| | | let icons = [] |
| | | for (const [key, component] of Object.entries(ElementPlusIconsVue)) { |
| | | icons.push(key) |
| | | } |
| | | export default { |
| | | name: "supplier", |
| | | data(){ |
| | | return { |
| | | dialogImageUrl: "", |
| | | action: "", |
| | | dialogVisible: false, |
| | | latticeList: [], |
| | | ImageUrlList: [], |
| | | } |
| | | }, |
| | | created(){ |
| | | |
| | | }, |
| | | mounted(){ |
| | | this.getTreeList(); |
| | | }, |
| | | components: { |
| | | ...ElementPlusIconsVue |
| | | }, |
| | | methods: { |
| | | viewUrl(item1) { |
| | | this.dialogVisible = true; |
| | | this.dialogImageUrl = item1.url; |
| | | }, |
| | | editData(index) { |
| | | this.latticeList[index].status = 0; |
| | | }, |
| | | delData(index) { |
| | | this.$confirm('å é¤','æç¤º', { |
| | | type: 'warning', |
| | | }).then(() => { |
| | | this.$HTTP.delete(`/api/blade-system/gallery/remove`,[this.latticeList[index].id]).then(res=> { |
| | | if(res.code == 200) { |
| | | this.getTreeList(); |
| | | this.$message.success("æä½æå"); |
| | | }else { |
| | | this.$alert(res.message, "æç¤º", {type: 'error'}); |
| | | } |
| | | }) |
| | | }).catch(() => { |
| | | //åæ¶ |
| | | }) |
| | | }, |
| | | addLattice(index) { |
| | | var obj = {}; |
| | | if(this.latticeList[index].id) { |
| | | Object.assign(obj,this.latticeList[index]); |
| | | obj.status = 1; |
| | | var method = "put"; |
| | | var url = "/api/blade-system/gallery/update"; |
| | | }else { |
| | | obj.name = this.latticeList[index].name; |
| | | var method = "post"; |
| | | var url = "/api/blade-system/gallery/insert"; |
| | | } |
| | | if (this.latticeList.some(item => item.name == "")) { |
| | | this.$message.error("å¾åºåç§°ä¸è½ä¸ºç©ºï¼"); |
| | | return; |
| | | }else { |
| | | this.$HTTP[method](url,obj).then(res=> { |
| | | if(res.code == 200) { |
| | | this.getTreeList(); |
| | | } |
| | | }) |
| | | } |
| | | }, |
| | | getTreeList() { |
| | | this.$HTTP.get("/api/blade-system/gallery/tree?itemCount=999").then(res=> { |
| | | if(res.code == 200) { |
| | | this.latticeList = res.data; |
| | | } |
| | | }) |
| | | }, |
| | | cencelLattice(index) { |
| | | if(this.latticeList[index].id) { |
| | | this.latticeList[index].status = 1; |
| | | }else { |
| | | this.latticeList.splice(index,1); |
| | | } |
| | | }, |
| | | beforeAvatarUpload(file,index) { |
| | | if(this.latticeList[index].id) { |
| | | this.action = `/api/blade-system/gallery-item/insert?galleryId=${this.latticeList[index].id}`; |
| | | }else { |
| | | return false; |
| | | } |
| | | }, |
| | | handleRemove(file, fileList) { |
| | | console.log(file, fileList); |
| | | }, |
| | | handlePictureCardPreview(file) { |
| | | |
| | | }, |
| | | handleAvatarSuccess(file,index) { |
| | | this.latticeList[index].ImageUrlList.push({ |
| | | url: file.url |
| | | }) |
| | | }, |
| | | table_create() { |
| | | this.latticeList.push({name: "",ImageUrlList: [],status: 0}) |
| | | }, |
| | | create_list() { |
| | | this.latticeList.unshift({name: "",ImageUrlList: [],status: 0}) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .main { |
| | | border: 1px solid #dcdfe6; |
| | | box-shadow: 0 2px 4px 0 rgba(0,0,0,.12), 0 0 6px 0 rgba(0,0,0,.04); |
| | | margin: 8px; |
| | | padding: 8px; |
| | | background-color: #fff; |
| | | min-height: 100%; |
| | | } |
| | | .noData { |
| | | display: flex; |
| | | flex-direction: column; |
| | | align-items: center; |
| | | justify-content: center; |
| | | height: 300px; |
| | | font-size: 16px; |
| | | color: #5e6d82; |
| | | } |
| | | .add-sure { |
| | | color: #409eff; |
| | | margin: 0 10px; |
| | | cursor: pointer; |
| | | } |
| | | .cencel { |
| | | cursor: pointer; |
| | | color: #fa554c; |
| | | } |
| | | .delData { |
| | | cursor: pointer; |
| | | color: #fa554c; |
| | | font-size: 14px; |
| | | font-weight: 700; |
| | | } |
| | | .edit { |
| | | color: #409eff; |
| | | font-size: 14px; |
| | | font-weight: 700; |
| | | cursor: pointer; |
| | | margin-right: 12px; |
| | | } |
| | | .title { |
| | | font-size: 16px; |
| | | font-weight: 700; |
| | | margin-right: 20px; |
| | | } |
| | | .upload { |
| | | margin-top: 12px; |
| | | margin-bottom: 12px; |
| | | } |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <!-- |
| | | * @Author: lzhe lzhe@example.com |
| | | * @Date: 2024-03-26 10:28:33 |
| | | * @LastEditors: lzhe lzhe@example.com |
| | | * @LastEditTime: 2024-06-05 15:15:52 |
| | | * @FilePath: /smart-web/src/views/master/person/main/index.vue |
| | | * @Description: è¿æ¯é»è®¤è®¾ç½®,请设置`customMade`, æå¼koroFileHeaderæ¥çé
ç½® è¿è¡è®¾ç½®: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |
| | | --> |
| | | <template> |
| | | <div class="user-main"> |
| | | <div class="user-top"> |
| | | <div class="right-bottom"> |
| | | <el-button type="primary" @click="addSupplier">æ°å»º</el-button> |
| | | <el-button type="danger" plain @click="delSupplier" :disabled="selection.length == 0">å é¤</el-button> |
| | | </div> |
| | | <div> |
| | | <el-input v-model="searchData.keyword" placeholder="è¾å
¥æ£ç´¢å
容" style="width: 180px;margin-right: 8px;" clearable> |
| | | <template #suffix><el-button type="primary" text @click="searchclick">æç´¢</el-button></template> |
| | | </el-input> |
| | | </div> |
| | | </div> |
| | | <div class="user-table"> |
| | | <el-table ref="multipleTableRef" :data="tableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="code" label="ä¾åºåç¼å·"></el-table-column> |
| | | <el-table-column prop="name" label="ä¾åºååç§°"></el-table-column> |
| | | <el-table-column prop="address" label="ä¾åºåå°å"></el-table-column> |
| | | <el-table-column prop="tel" label="èç³»æ¹å¼"></el-table-column> |
| | | <el-table-column fixed="right" label="æä½"> |
| | | <template #default="scope"> |
| | | <el-button type="text" size="small" @click="table_edit(scope.row, scope.$index)">ç¼è¾</el-button> |
| | | <el-button text type="primary" size="small" @click="table_del(scope.row, scope.$index)">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <el-pagination |
| | | style="margin-top: 12px;" |
| | | @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | :current-page="currentPage4" |
| | | :page-sizes="[15, 50, 100]" |
| | | :page-size="15" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="total"> |
| | | </el-pagination> |
| | | </div> |
| | | </div> |
| | | |
| | | <save-dialog v-if="dialog.save" ref="saveDialog" @success="addUserSuccess" @closed="dialog.save=false"></save-dialog> |
| | | </template> |
| | | <script> |
| | | import saveDialog from './addSupplierInfo' |
| | | export default { |
| | | name: "supplier", |
| | | data(){ |
| | | return { |
| | | selection: [], |
| | | searchData: { |
| | | keyword: "", |
| | | current: "1", |
| | | size: "15" |
| | | }, |
| | | total: 0, |
| | | isSaveing: false, |
| | | dialog: { |
| | | save: false |
| | | }, |
| | | leftActive: true, |
| | | tableData: [] |
| | | } |
| | | }, |
| | | created(){ |
| | | |
| | | }, |
| | | mounted(){ |
| | | this.searchSupplier(); |
| | | }, |
| | | components: { |
| | | saveDialog |
| | | }, |
| | | methods: { |
| | | addUserSuccess() { |
| | | this.searchclick(); |
| | | }, |
| | | table_del(row) { |
| | | this.$confirm('ç¡®å®å°éæ©æ°æ®å é¤?','æç¤º', { |
| | | type: 'warning', |
| | | }).then(() => { |
| | | this.$HTTP.delete(`/api/blade-cps/supplier/remove?supplierIds=${row.id}`).then(res=> { |
| | | if(res.code == 200) { |
| | | this.searchclick(); |
| | | this.$message.success("æä½æå"); |
| | | }else { |
| | | this.$alert(res.message, "æç¤º", {type: 'error'}); |
| | | } |
| | | }) |
| | | }).catch(() => { |
| | | //åæ¶ |
| | | }) |
| | | }, |
| | | searchclick() { |
| | | this.searchData.current = "1"; |
| | | this.searchData.size = "15"; |
| | | this.searchSupplier(); |
| | | }, |
| | | searchSupplier() { |
| | | this.$HTTP.get("/api/blade-cps/supplier/page",this.searchData).then(res=> { |
| | | if(res.code == 200) { |
| | | res.data.records.forEach(item=> { |
| | | if(item.status == "1") { |
| | | item.status = true; |
| | | }else { |
| | | item.status = false; |
| | | } |
| | | }) |
| | | this.tableData = res.data.records; |
| | | this.total = res.data.total; |
| | | } |
| | | }) |
| | | }, |
| | | //æ·»å |
| | | addSupplier(){ |
| | | this.dialog.save = true |
| | | this.$nextTick(() => { |
| | | this.$refs.saveDialog.open() |
| | | }) |
| | | }, |
| | | table_edit(row){ |
| | | this.dialog.save = true |
| | | this.$nextTick(() => { |
| | | this.$refs.saveDialog.open('edit').setData(row) |
| | | }) |
| | | }, |
| | | //æ¥ç |
| | | table_show(row){ |
| | | this.dialog.save = true |
| | | this.$nextTick(() => { |
| | | this.$refs.saveDialog.open('show').setData(row) |
| | | }) |
| | | }, |
| | | handleSelectionChange(selection) { |
| | | this.selection = selection; |
| | | }, |
| | | delSupplier() { |
| | | if(this.selection.length == 0) { |
| | | this.$message({ |
| | | message: 'è¯·éæ©è³å°ä¸æ¡æ°æ®', |
| | | type: 'warning' |
| | | }); |
| | | return; |
| | | } |
| | | var selStr = ""; |
| | | this.selection.map(item=> { |
| | | selStr += item.id + "," |
| | | }) |
| | | selStr = selStr.replace(/,$/, ''); |
| | | var that = this; |
| | | this.$confirm('ç¡®å®å°éæ©æ°æ®å é¤ï¼','æç¤º', { |
| | | type: 'warning', |
| | | }).then(() => { |
| | | that.$HTTP.delete("/api/blade-cps/supplier/remove?supplierIds="+selStr).then(res=> { |
| | | if(res.code == 200) { |
| | | that.$message.success("æä½æå"); |
| | | that.searchSupplier(); |
| | | } |
| | | }) |
| | | }).catch(() => { |
| | | //åæ¶ |
| | | }) |
| | | }, |
| | | handleSizeChange(val) { |
| | | console.log(`æ¯é¡µ ${val} æ¡`); |
| | | this.searchData.current = "1"; |
| | | this.searchData.size = val; |
| | | this.searchSupplier(); |
| | | }, |
| | | handleCurrentChange(val) { |
| | | console.log(`å½å页: ${val}`); |
| | | this.searchData.current = val; |
| | | this.searchSupplier(); |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .user-main { |
| | | background-color: #f9fafb; |
| | | border: 1px solid #dcdfe6; |
| | | box-shadow: 0 2px 4px 0 rgba(0,0,0,.12), 0 0 6px 0 rgba(0,0,0,.04); |
| | | margin: 8px; |
| | | padding: 8px; |
| | | background-color: #fff; |
| | | } |
| | | .user-top { |
| | | width: 100%; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | margin-bottom: 8px; |
| | | } |
| | | .user-table { |
| | | width: 100%; |
| | | margin-bottom: 8px; |
| | | |
| | | } |
| | | .multipleTableRef { |
| | | margin-bottom: 8px; |
| | | } |
| | | </style> |