123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- <template>
- <div class="equipment-box">
- <moduleView :propConfig="config" ref="view" v-loading="load" @pagination="pagination" @modalHandle="modalHandle" @onRefresh="getList"
- @resert="queryList" @search="queryList" @clickHandle="clickHandle" @detail="detail" />
- <adModal ref="adModalView" @successHandle="queryList" />
- </div>
- </template>
- <script setup>
- import stateRadio from './components/stateRadio.vue';
- import adModal from './components/adModal.vue';
- import { list, add, adSetting, update,del,adList,adMove } from '@/api/base/equipment.js'
- import { computed,getCurrentInstance,ref,markRaw,shallowRef } from "vue";
- const { proxy } = getCurrentInstance();
- const load = ref(false)
- const isSearch = ref(false)
- const time= ref(null);
- const timeNum = ref(0);
-
- const config = ref({
- attr:{
- calculateH:true
- },
- search:{
- columns:[
- [{
- span:6,
- // label:'设备名称',
- labelWidth:1,
- prop:'searchText',
- component:'by-input',
- compConfig:{
- attr:{
- placeholder:'请输入设备编码、设备名称、维修人、维修电话',
- prefixIcon:'vxe-icon-search'
- }
- }
- },{
- span:6,
- labelWidth:80,
- label:'状态',
- prop:'state',
- component:'by-select',
- compConfig:{
- attr:{
- clearable:true,
- placeholder:'状态',
- data:[{
- label:'开启',
- value:1
- },{
- label:'关闭',
- value:0
- }]
- }
- }
- },
- {
- span:6,
- labelWidth:100,
- label:'在线状态',
- prop:'onState',
- component:'by-select',
- compConfig:{
- attr:{
- clearable:true,
- placeholder:'在线状态',
- data:[{
- label:'在线',
- value:1
- },{
- label:'休眠',
- value:0
- }]
- }
- }
- }
- ]
- ]
- },
- tool:{
- tools:{
- add:true,
- delete:true,
- search:true,
- refresh:true
- }
- },
- table:{
- attr:{
- size:'mini',
- // seq:true,
- align:'center',
- checkbox:true
- },
- columns:[{
- title:'设备编码',
- field:'equipmentCode',
- width:80
- },
- {
- title:'设备名称',
- field:'equipmentName',
- isDetail:true,
- width:100
- },
- {
- title:'状态',
- field:'state',
- component:'textChange',
- compConfig:{
- attr:{
- data:[{
- label:'开启',
- value:1,
- backgroundColor:'#f0f9eb',
- color:'#67c23a'
- },{
- label:'关闭',
- value:0,
- backgroundColor:'#fef0f0',
- color:'#f56c6c'
- }]
- }
- }
- },
- {
- title:'在线状态',
- field:'onState',
- component:'textChange',
- compConfig:{
- attr:{
- data:[{
- label:'在线',
- value:1,
- backgroundColor:'#f0f9eb',
- color:'#67c23a'
- },{
- label:'休眠',
- value:0,
- backgroundColor:'#fef0f0',
- color:'#f56c6c'
- }]
- }
- }
- },
- {
- title:'所属厂家',
- field:'manufacturers'
- },
- {
- title:'维修人',
- field:'maintainName'
- },
- {
- title:'维修电话',
- field:'maintainTelephone'
- },
- {
- title:'加入时间',
- field:'enterTime'
- },
- {
- title:'操作',
- action:true,
- plugins:[{
- name:'广告设置',
- audit:'',
- event:{
- click:item => {
- adSet(item)
- }
- }
- }]
- }]
- },
- modal:{
- tool:{
- tools:{
- return:true,
- add:true
- }
- },
- form:{
- attr:{
- width:'1000px',
- size:'small',
- labelWidth:'130px',
- rules:{
- equipmentCode:[
- {required: true, message: '请输入设备编码', trigger: 'blur'}
- ],
- equipmentName:[
- {required: true, message: '请输入设备名称', trigger: 'blur'}
- ],
- manufacturers:[
- {required: true, message: '请输入所属厂家', trigger: 'blur'}
- ],
- state:[
- {required: true, message: '请选择状态', trigger: 'blur'},
- ],
- addrCode:[
- {required: true, message: '请选择位置', trigger: 'blur'}
- ],
- addrInfo:[
- {required: true, message: '请输入详细地址', trigger: 'blur'}
- ],
- maintainName:[
- {required: true, message: '请输入维修人', trigger: 'blur'},
- ],
- onState:[
- {required: true, message: '请输入在线状态', trigger: 'blur'},
- ],
- maintainTelephone:[
- {required: true, message: '请输入维修人电话', trigger: 'blur'},
- { validator: (rule, value, callback) => {
- if (value) {
- if(!/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(value)) {
- callback(new Error('手机号格式不正确!'));
- }else{
- callback();
- }
- } else {
- callback();
- }
- }, trigger: 'blur' }
- ]
- }
- },
- columns:[
- [{
- label:'设备编码',
- prop:'equipmentCode',
- component:'by-input',
- compConfig:{
- attr:{}
- }
- },{
- label:'设备名称',
- prop:'equipmentName',
- component:'by-input',
- compConfig:{
- attr:{}
- }
- }],
- [{
- label:'所属厂家',
- span:12,
- prop:'manufacturers',
- component:'by-input',
- compConfig:{
- attr:{}
- }
- }
- ,{
- label:'状态',
- prop:'state',
- component:'by-select',
- compConfig:{
- attr:{
- clearable:true,
- data:[{
- label:'开启',
- value:1
- },{
- label:'关闭',
- value:0
- }]
- }
- }
- }
- ],
- [{
- label:'在线状态',
- prop:'onState',
- component:shallowRef(stateRadio)
- }],
- [{
- label:'维修人',
- prop:'maintainName',
- component:'by-input'
- },{
- label:'维修电话',
- prop:'maintainTelephone',
- component:'by-input'
- }],
- // [{
- // label:'授权状态',
- // prop:'state',
- // component:shallowRef(stateRadio)
- // }],
- [{
- label:'位置',
- prop:'addrCode',
- component:'by-area',
- compConfig:{
- attr:{
- area:'addrCodeInfo',
- areaCode:'addrCode'
- }
- }
- }],
- [{
- label:'详细地址',
- prop:'addrInfo',
- component:'by-input'
- }],
- [{
- label:'标记',
- prop:'lnglat',
- component:'MapMaker',
- compConfig:{
- attr:{
- lng:'lng',
- lat:'lat'
- }
- }
- }],
- [{
- label:'备注',
- prop:'remark',
- component:'by-input',
- compConfig:{
- attr:{
- type:'textarea'
- }
- }
- }]
- ]
- }
- }
- })
- const adSet = row => {
- proxy.$refs.adModalView.setShow(true);
- proxy.$refs.adModalView.setValue(row)
- }
-
- const clickHandle = n => {
- if(n == 'onAdd'){
- config.value.modal.tool.tools.add = true;
- delete config.value.modal.tool.tools.save;
- proxy.$refs.view.initFormTool();
- }
- if(n == 'onDelete'){
- delHandle()
- }
- }
- const modalHandle = n =>{
- if(n == 'onAdd'){
- proxy.$refs.view.getFormValidate(addData)
- }
- if(n == 'onSave'){
- proxy.$refs.view.getFormValidate(onSave)
- }
- }
- //添加
- const addData = () => {
- let value = proxy.$refs.view.getFormValue();
- if(value){
- load.value = true;
- add(value).then(res =>{
- load.value = false;
- proxy.$message({
- message:res.msg,
- type:'success'
- });
- proxy.$refs.view.closeModal();
- getList();
- }).catch(()=>{
- load.value = false;
- })
- }
- }
- //保存
- const onSave = () => {
- let data = proxy.$refs.view.getFormValue();
- load.value = true;
- update(data).then(res => {
- proxy.$message({
- message:res.msg,
- type:'success'
- });
- load.value = false;
- proxy.$refs.view.closeModal();
- pagination();
- }).catch(() => {
- load.value = false;
- })
- }
- const delHandle = () => {
- let data = proxy.$refs.view.getSelectData();
- let ids = []
- if(!data && data.lenght == 0) {
- proxy.$message('请选择数据')
- return
- }
- for(const item of data) {
- ids.push(item.equipmentId)
- }
- proxy.$confirm('此操作将永久删除数据, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- load.value = true;
- del({
- equipmentIds:ids,
- }).then(()=>{
- proxy.$message({message:'删除成功!',type:'success'})
- load.value = false;
- getList();
- }).catch(()=>{
- load.value = false;
- })
- }).catch(()=>{})
- }
- const detail = () => {
- config.value.modal.tool.tools.save = true;
- delete config.value.modal.tool.tools.add;
- proxy.$refs.view.initFormTool();
- }
- const pagination = () => {
- if(isSearch.value){
- queryList();
- }else{
- getList()
- }
- }
- //列表请求(包含分页和搜素条件)
- const queryList = () => {
- isSearch.value = true;
- let data = proxy.$refs.view.getQuery();
- requestList(data);
- }
- const getList = () => {
- if(!proxy.$refs.view){
- if(timeNum.value > 5){
- return
- }
- setTimeout(()=>{
- getList()
- },500)
- timeNum.value ++;
- return
- }
- timeNum.value = 0;
- isSearch.value = false;
- let data = proxy.$refs.view.getPage();
- requestList(data);
- }
- const requestList = data => {
- load.value = true;
- list(data).then(res => {
- load.value = false;
- proxy.$refs.view.setTableValue(res.data.data);
- let page = {
- pageNo: res.data.page.current, //当前页
- pageSize: data.pageSize, //每页条数
- total: res.data.page.total //总条数
- };
- proxy.$refs.view.setPage(page)
- }).catch(()=>{
- load.value = false;
- })
- }
- nextTick(()=>{
- getList()
- })
- </script>
- <style lang="scss" scoped>
- .equipment-box{
- width: 100%;
- height: 100%;
- }
- .equip-info{
- padding: 8px 16px;
- width: 100%;
- box-sizing: border-box;
- background-color: rgba(255,240,184,0.95);
- font-size: 12px;
- margin-bottom: 16px;
- .equip-state{
- .norm{
- color: #00AE66;
- }
- .disa{
- color: red;
- }
- }
- }
- .page{
- width: 100%;
- display: flex;
- justify-content: flex-end;
- align-items: center;
- padding-top: 8px;
- }
- </style>
|