4/25 优化代码 1.1.2
							parent
							
								
									502b335c79
								
							
						
					
					
						commit
						8851588265
					
				| @ -0,0 +1,379 @@ | |||||||
|  | <template> | ||||||
|  | <div> | ||||||
|  |       <el-card> | ||||||
|  |         <el-form v-if="queryList1 && queryList1.length > 0" :model="filterQuery" class="query-form" size="mini" label-width="120px" v-show="showSearch" :inline="true"> | ||||||
|  |           <el-row style=" display:flex;  flex-wrap: wrap; "> | ||||||
|  |             <template v-for="(item, index) in queryList1" > | ||||||
|  |               <el-form-item v-if="item.columnType == 'input' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`" :key="item.id"> | ||||||
|  |                 <el-input | ||||||
|  |                   v-model="filterQuery[item.columnName]" | ||||||
|  |                   :placeholder="item.columnDesc" | ||||||
|  |                   :disabled="executeEval(null,item.disabledFuc,false)" | ||||||
|  |                   @keyup.enter.native="executeFuc($event,'5',item.clickFuc)" | ||||||
|  |                   clearable | ||||||
|  |                 ></el-input> | ||||||
|  |               </el-form-item> | ||||||
|  |               <el-form-item v-if="item.columnType == 'select' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`"> | ||||||
|  |                 <el-select v-model="filterQuery[item.columnName]" | ||||||
|  |                            :placeholder="item.columnDesc" | ||||||
|  |                            :disabled="executeEval(null,item.disabledFuc,false)" | ||||||
|  |                            clearable> | ||||||
|  |                   <el-option | ||||||
|  |                     v-for="dict in item.lableRuleObj" | ||||||
|  |                     :key="dict.value" | ||||||
|  |                     :label="dict.label" | ||||||
|  |                     :value="dict.value" | ||||||
|  |                   /> | ||||||
|  |                 </el-select> | ||||||
|  |               </el-form-item> | ||||||
|  |               <el-form-item v-if="item.columnType == 'selectServer' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`"> | ||||||
|  |                 <el-select | ||||||
|  |                   v-model="filterQuery[item.columnName]" | ||||||
|  |                   :placeholder="item.columnDesc" | ||||||
|  |                   @change="executeFuc($event,'5',item.checkRules)" | ||||||
|  |                   :disabled="executeEval(null,item.disabledFuc,false)" | ||||||
|  |                   filterable | ||||||
|  |                   remote | ||||||
|  |                   :remote-method="(query) => executeFuc(query,'5',item.clickFuc)" | ||||||
|  |                   clearable> | ||||||
|  |                   <el-option | ||||||
|  |                     v-for="item in options[item.clickFuc]" | ||||||
|  |                     :key="item.code" | ||||||
|  |                     :label="item.label" | ||||||
|  |                     :value="item.code" | ||||||
|  |                   /> | ||||||
|  |                 </el-select> | ||||||
|  |               </el-form-item> | ||||||
|  |               <el-form-item v-if="item.columnType == 'datePicker' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`"> | ||||||
|  |                 <el-date-picker | ||||||
|  |                   :picker-options="pickerOptions" | ||||||
|  |                   v-model="actDateRange" | ||||||
|  |                   type="daterange" | ||||||
|  |                   format="yyyy 年 MM 月 dd 日" | ||||||
|  |                   value-format="yyyy-MM-dd" | ||||||
|  |                   range-separator="至" | ||||||
|  |                   start-placeholder="开始日期" | ||||||
|  |                   end-placeholder="结束日期" | ||||||
|  |                 ></el-date-picker> | ||||||
|  |               </el-form-item> | ||||||
|  |               <el-form-item v-if="item.columnType == 'date' && executeEval(row,item.expression,true)" :label="item.columnDesc+`:`"> | ||||||
|  |                 <el-date-picker | ||||||
|  |                   v-model="filterQuery[item.columnName]" | ||||||
|  |                   :style="`width:${item.width+'px'}`" | ||||||
|  |                   value-format="yyyy-MM-dd" | ||||||
|  |                   :disabled="executeEval(null,item.disabledFuc,false)" | ||||||
|  |                   type="date" | ||||||
|  |                   :placeholder="item.columnDesc" | ||||||
|  |                 ></el-date-picker> | ||||||
|  |               </el-form-item> | ||||||
|  |             </template> | ||||||
|  |           </el-row> | ||||||
|  |         </el-form> | ||||||
|  |         <div class="top-right-btn"> | ||||||
|  |           <el-button-group> | ||||||
|  |             <el-button icon="el-icon-view" type="primary" @click="hideSearch">显示/隐藏搜索栏</el-button> | ||||||
|  |             <el-button | ||||||
|  |               type="primary" | ||||||
|  |               icon="el-icon-refresh" | ||||||
|  |               @click="onReset" | ||||||
|  |             >重置 | ||||||
|  |             </el-button> | ||||||
|  |             <el-button type="primary" icon="el-icon-search" @click="onSubmit" | ||||||
|  |             >查询 | ||||||
|  |             </el-button | ||||||
|  |             > | ||||||
|  |             <el-button type="primary" icon="el-icon-plus" @click="confrim">选入</el-button> | ||||||
|  |           </el-button-group> | ||||||
|  |         </div> | ||||||
|  |         <el-table | ||||||
|  |           :data="list" | ||||||
|  |           style="width: 100%" | ||||||
|  |           border | ||||||
|  |           highlight-current-row="true" | ||||||
|  |           :row-class-name="tableRowClassName" | ||||||
|  |           @current-change="handleErpChange" | ||||||
|  |           @selection-change="handleSelectionUdiChange" | ||||||
|  |           ref="multipleTable" | ||||||
|  |         > | ||||||
|  |           <el-table-column width="55"> | ||||||
|  |             <template slot-scope="scope"> | ||||||
|  |               <el-radio :label="scope.row.id" v-model="radioCheck" :disabled="scope.row.check"><span></span></el-radio> | ||||||
|  |             </template> | ||||||
|  |           </el-table-column> | ||||||
|  | 
 | ||||||
|  |           <template v-for="(item, index) in tableHeader1"> | ||||||
|  |             <el-table-column | ||||||
|  |               v-if="item.columnType == 'id' && executeEval(row,item.expression,true)" | ||||||
|  |               type="index" :label="item.columnDesc"></el-table-column> | ||||||
|  |             <el-table-column | ||||||
|  |               v-if="item.columnType == 'selection'" | ||||||
|  |               type="selection" | ||||||
|  |               :width="item.width" | ||||||
|  |               :selectable="(row,number) => executeFuc(row,'3',item.clickFuc)" | ||||||
|  |             ></el-table-column> | ||||||
|  | 
 | ||||||
|  |             <el-table-column | ||||||
|  |               v-if="item.columnType == 'radio' && executeEval(row,item.expression,true)" | ||||||
|  |               :prop="item.columnName" | ||||||
|  |               :label="item.columnDesc" | ||||||
|  |               :sortable="item.sort" | ||||||
|  |               :width="item.width" | ||||||
|  |               :show-overflow-tooltip="item.tooltip" | ||||||
|  |               :key="item.columnName" | ||||||
|  |             > | ||||||
|  |               <template  slot-scope="scope"> | ||||||
|  |                 <el-radio :label="scope.row.id" v-model="radioCheck"><span></span></el-radio> | ||||||
|  |               </template> | ||||||
|  |             </el-table-column> | ||||||
|  |             <el-table-column | ||||||
|  |               v-if="item.columnType == 'laber' && executeEval(row,item.expression,true)" | ||||||
|  |               :prop="item.columnName" | ||||||
|  |               :label="item.columnDesc" | ||||||
|  |               :sortable="item.sort" | ||||||
|  |               :width="item.width" | ||||||
|  |               :show-overflow-tooltip="item.tooltip" | ||||||
|  |               :key="item.columnName" | ||||||
|  |             > | ||||||
|  |               <template   slot-scope="scope"> | ||||||
|  |                 <span :style="{color: executeFuc(scope.row,'4',item.lableRuleObj[scope.row[item.columnName]])}">{{ item.lableRuleObj[scope.row[item.columnName]] }}</span> | ||||||
|  |               </template> | ||||||
|  |             </el-table-column> | ||||||
|  |             <el-table-column | ||||||
|  |               v-if="item.columnType == 'eltag' && executeEval(row,item.expression,true)" | ||||||
|  |               :prop="item.columnName" | ||||||
|  |               :label="item.columnDesc" | ||||||
|  |               :sortable="item.sort" | ||||||
|  |               :width="item.width" | ||||||
|  |               :show-overflow-tooltip="item.tooltip" | ||||||
|  |               :key="item.columnName" | ||||||
|  |             > | ||||||
|  |               <template   slot-scope="scope"> | ||||||
|  |                 <el-tag :type="executeFuc(scope.row,'4',item,item.lableRuleObj?item.lableRuleObj[scope.row[item.columnName]]:scope.row[item.columnName])"> | ||||||
|  |                   <span>{{ item.lableRuleObj?item.lableRuleObj[scope.row[item.columnName]]:scope.row[item.columnName] }}</span> | ||||||
|  |                 </el-tag> | ||||||
|  |               </template> | ||||||
|  |             </el-table-column> | ||||||
|  |             <!--<el-table-column--> | ||||||
|  |             <!--  v-if="item.columnType == 'button' && executeEval(row,item.expression,true)"--> | ||||||
|  |             <!--  :prop="item.columnName"--> | ||||||
|  |             <!--  :label="item.columnDesc"--> | ||||||
|  |             <!--  :width="item.width"--> | ||||||
|  |             <!--  :key="item.columnName"--> | ||||||
|  |             <!--  fixed="right"--> | ||||||
|  |             <!-->--> | ||||||
|  |             <!--  <template slot-scope="scope">--> | ||||||
|  |             <!--    <el-button v-for="(buttonItem, buttonIndex) in item.buttonRulObj"--> | ||||||
|  |             <!--               :type="buttonItem.type"--> | ||||||
|  |             <!--               :size="buttonItem.size"--> | ||||||
|  |             <!--               :style="buttonItem.style"--> | ||||||
|  |             <!--               :key="buttonItem"--> | ||||||
|  |             <!--               v-if="executeEval(scope.row,buttonItem.hasPermi,true)"--> | ||||||
|  |             <!--               :disabled="executeEval(scope.row,buttonItem.disabledFuc,false)"--> | ||||||
|  |             <!--               @click.native.stop="executeFuc(scope.row,'1',buttonItem.clickFuc)"--> | ||||||
|  |             <!--    >{{ buttonItem.name }}--> | ||||||
|  |             <!--    </el-button>--> | ||||||
|  |             <!--  </template>--> | ||||||
|  |             <!--</el-table-column>--> | ||||||
|  |             <el-table-column | ||||||
|  |               v-if="item.columnType == 'text' && executeEval(row,item.expression,true)" | ||||||
|  |               :prop="item.columnName" | ||||||
|  |               :label="item.columnDesc" | ||||||
|  |               :sortable="item.sort" | ||||||
|  |               :width="item.width" | ||||||
|  |               :show-overflow-tooltip="item.tooltip" | ||||||
|  |               :key="item.columnName" | ||||||
|  |             > | ||||||
|  |               <template slot-scope="scope"> | ||||||
|  |                 <span :style="{color: executeFuc(scope.row,'4',item,scope.row[item.columnName])}">{{ scope.row[item.columnName] }}</span> | ||||||
|  |               </template> | ||||||
|  |             </el-table-column> | ||||||
|  |           </template> | ||||||
|  |         </el-table> | ||||||
|  | 
 | ||||||
|  |         <pagination | ||||||
|  |           v-show="total>0" | ||||||
|  |           :total="total" | ||||||
|  |           :page.sync="filterQuery.page" | ||||||
|  |           :limit.sync="filterQuery.limit" | ||||||
|  |           @pagination="handleCurrentChange" | ||||||
|  |         ></pagination> | ||||||
|  |       </el-card> | ||||||
|  | </div> | ||||||
|  | </template> | ||||||
|  | 
 | ||||||
|  | <script> | ||||||
|  | import { | ||||||
|  |   getHead,executeFuc | ||||||
|  | } from "@/utils/customConfig"; | ||||||
|  | import {list} from "@/api/anno/anncmntDev"; | ||||||
|  | export default { | ||||||
|  |   name: "announcementDialog", | ||||||
|  |   props:{ | ||||||
|  |     closeAnnoDialog: { | ||||||
|  |       type: Function, | ||||||
|  |       required: true, | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  |   data () | ||||||
|  |   { | ||||||
|  |     return { | ||||||
|  |       childValue: '我是子组件的数据', | ||||||
|  |       //新增 | ||||||
|  |       dialogTableVisible:false, | ||||||
|  |       textarea:'', | ||||||
|  |       body:{}, | ||||||
|  |       tableObj1 : [], | ||||||
|  |       tableHeader1 : [], | ||||||
|  |       queryList1 : [], | ||||||
|  |       fromList1 : [], | ||||||
|  |       filterQuery: { | ||||||
|  |         page: 1, | ||||||
|  |         limit: 10, | ||||||
|  |         // status:1, | ||||||
|  |       }, | ||||||
|  |       radioCheck: null, | ||||||
|  |       devSelection:[], | ||||||
|  |       currentRow: null, | ||||||
|  |       loading: false, | ||||||
|  |       actDateRange: [], | ||||||
|  |       pickerOptions: { | ||||||
|  |         shortcuts: [ | ||||||
|  |           { | ||||||
|  |             text: "最近一周", | ||||||
|  |             onClick(picker) { | ||||||
|  |               const end = new Date(); | ||||||
|  |               const start = new Date(); | ||||||
|  |               start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); | ||||||
|  |               picker.$emit("pick", [start, end]); | ||||||
|  |             }, | ||||||
|  |           }, | ||||||
|  |           { | ||||||
|  |             text: "最近一个月", | ||||||
|  |             onClick(picker) { | ||||||
|  |               const end = new Date(); | ||||||
|  |               const start = new Date(); | ||||||
|  |               start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); | ||||||
|  |               picker.$emit("pick", [start, end]); | ||||||
|  |             }, | ||||||
|  |           }, | ||||||
|  |           { | ||||||
|  |             text: "最近三个月", | ||||||
|  |             onClick(picker) { | ||||||
|  |               const end = new Date(); | ||||||
|  |               const start = new Date(); | ||||||
|  |               start.setTime(start.getTime() - 3600 * 1000 * 24 * 90); | ||||||
|  |               picker.$emit("pick", [start, end]); | ||||||
|  |             }, | ||||||
|  |           }, | ||||||
|  |         ], | ||||||
|  |       }, | ||||||
|  |       showSearch: true, | ||||||
|  |       list:[], | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   methods: { | ||||||
|  |     // childClick () { | ||||||
|  |     //   // childByValue是在父组件on监听的方法 | ||||||
|  |     //   // 第二个参数this.childValue是需要传的值 | ||||||
|  |     //   this.$emit('childByValue', this.childValue) | ||||||
|  |     // }, | ||||||
|  |     checkSelectable(row) { | ||||||
|  |       return !row.check; | ||||||
|  |     }, | ||||||
|  |     //新增 | ||||||
|  |     executeFuc(row,type,clickFuc,value){ | ||||||
|  |       return executeFuc(this,row,type,clickFuc,value); | ||||||
|  |     }, | ||||||
|  |     executeEval(row,expression,defaultRet){ | ||||||
|  |       if(expression){ | ||||||
|  |         return eval(expression); | ||||||
|  |       } | ||||||
|  |       return defaultRet; | ||||||
|  |     }, | ||||||
|  |     getDevList(){ | ||||||
|  |       // this.dialogTableVisible = true | ||||||
|  |       this.loading = true; | ||||||
|  |       list(this.filterQuery).then(res => { | ||||||
|  |         if (res.code == 20000){ | ||||||
|  |           this.loading = false; | ||||||
|  |           this.tableData = res.data | ||||||
|  |           this.list = res.data.list || []; | ||||||
|  |           this.total = res.data.total || 0; | ||||||
|  |           console.log("success",this.tableData) | ||||||
|  |         } | ||||||
|  |       }).catch(res => { | ||||||
|  |         this.loading = false; | ||||||
|  |         this.list = []; | ||||||
|  |         this.total = 0; | ||||||
|  |       }) | ||||||
|  |     }, | ||||||
|  |     hideSearch() { | ||||||
|  |       this.showSearch = !this.showSearch; | ||||||
|  |     }, | ||||||
|  |     onReset() { | ||||||
|  |       this.actDateRange = null; | ||||||
|  |       this.filterQuery = { | ||||||
|  |         page: 1, | ||||||
|  |         limit: 10, | ||||||
|  |         // status:1, | ||||||
|  |       } | ||||||
|  |       this.getDevList(); | ||||||
|  |     }, | ||||||
|  |     onSubmit() { | ||||||
|  |       if (this.actDateRange !== null) { | ||||||
|  |         this.filterQuery.startTime = this.actDateRange[0]; | ||||||
|  |         this.filterQuery.endTime = this.actDateRange[1]; | ||||||
|  |       } else { | ||||||
|  |         this.filterQuery.startTime = null; | ||||||
|  |         this.filterQuery.endTime = null; | ||||||
|  |       } | ||||||
|  |       this.filterQuery.page = 1; | ||||||
|  |       this.getDevList(); | ||||||
|  |     }, | ||||||
|  |     confrim(){ | ||||||
|  |       // this.closeDialog(); | ||||||
|  |       // console.log("wozaici dayin yicia zhege ", this.devSelection) | ||||||
|  |       const val = this.devSelection; | ||||||
|  |       this.textarea = val[0].annContent | ||||||
|  |       this.$emit('childByValue', this.textarea) | ||||||
|  |       this.closeAnnoDialog(); | ||||||
|  |     }, | ||||||
|  |     tableRowClassName({row, rowIndex}) { | ||||||
|  |       if (row.check) return "warning-row"; | ||||||
|  |       return ""; | ||||||
|  |     }, | ||||||
|  |     handleErpChange(val) { | ||||||
|  |       // console.log("dianjij handleErpChange",val) | ||||||
|  |       if (!val.check) { | ||||||
|  |         this.radioCheck = val.id; | ||||||
|  |         // this.cpmctymc1 = val.cpmctymc; | ||||||
|  |         this.currentRow = val; | ||||||
|  |         this.$refs.multipleTable.clearSelection(); | ||||||
|  |         this.$refs.multipleTable.toggleRowSelection(val); | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     handleSelectionUdiChange(val) { | ||||||
|  |       // console.log("dayin dayin handleSelectionUdiChange ",val) | ||||||
|  |       this.devSelection = val; | ||||||
|  |     }, | ||||||
|  |     handleCurrentChange(val) { | ||||||
|  |       this.filterQuery.page = val.page; | ||||||
|  |       this.getDevList(); | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  |   created() { | ||||||
|  |     getHead("anncmntDev","1").then((re) => { | ||||||
|  |       // 处理返回的数据 | ||||||
|  |       this.tableObj1 = re.data; | ||||||
|  |       this.tableHeader1 = re.data.tableList; | ||||||
|  |       this.queryList1 = re.data.queryList; | ||||||
|  |       this.fromList1 = re.data.fromList; | ||||||
|  |       this.getDevList(); | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|  | } | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <style scoped> | ||||||
|  | 
 | ||||||
|  | </style> | ||||||
					Loading…
					
					
				
		Reference in New Issue