zmc
2023-09-27 eeef5d4039d2b3fee6854ddc2789aa23232b2cfb
src/views/setting/SetConfiguration.vue
@@ -1,76 +1,176 @@
<script>
import {useCounterStore} from '@/stores/counter';
import TimeSelectWithShortCuts from '@/sfc/TimeSelectWithShortCuts.vue'
import settingApi from '@/api/data_access_setting/settingApi.js'
import dayjs from 'dayjs'
import { ElMessage } from 'element-plus'
// import exceptionApi from '@/api/exceptionApi.js'
export default {
   data(){
      return{
  components: {
    TimeSelectWithShortCuts
  },
  data() {
    return {
      // 区域
      radio: 0,
      // 定时
      radio1: '',
      beginTime: '',
      endTime: '',
      }
   },
   setup(){
    const store = useCounterStore()
    const unsubscribe = store.$onAction(
  ({
    name, // action 的名字
    store, // store 实例
    args, // 调用这个 action 的参数
    after, // 在这个 action 执行完毕之后,执行这个函数
    onError, // 在这个 action 抛出异常的时候,执行这个函数
  }) => {
    // 记录开始的时间变量
    const startTime = Date.now()
    // 这将在 `store` 上的操作执行之前触发
    console.log(`Start "${name}" with params [${args.join(', ')}].`)
    // 如果 action 成功并且完全运行后,after 将触发。
    // 它将等待任何返回的 promise
    after((result) => {
      console.log(
        `Finished "${name}" after ${
          Date.now() - startTime
        }ms.\nResult: ${result}.`
      )
    })
    // 如果 action 抛出或返回 Promise.reject ,onError 将触发
    onError((error) => {
      console.warn(
        `Failed "${name}" after ${Date.now() - startTime}ms.\nError: ${error}.`
      )
    })
  }
)
    return{
      store,unsubscribe
      // a :[],
      // exception: {
      //   // 断电或断网
      //   exception0: [],
      //   // 数据超低
      //   exception1: [],
      //   // 超标
      //   exception2: [],
      //   // 数据长时段无波动
      //   exception3: [],
      //   // 量级突变异常
      //   exception4: [],
      // }
    }
   },
   computed:{
    a(){
      return this.store.doubleCount*2
  },
  mounted() {
    // this.get()
    // this.getAll()
    console.log('时间',new Date().getMilliseconds());
  },
  methods: {
    giveTime(val) {
      //将中国标准时间转为指定格式(该组件返回的标准时间的格式,所以必须的加这个函数)
      this.beginTime = dayjs(val[0]).format('YYYY-MM-DD HH:mm:ss')
      this.endTime = dayjs(val[1]).format('YYYY-MM-DD HH:mm:ss')
    },
    set() {
      const params = {}
      params.user = 'admin'
      params.beginTime = this.beginTime
      params.endTime = this.endTime
      params.region = '金山'
      params.isRegularTime = this.radio1
      settingApi.submitSetting(params).then((res) => {
        if (res.data.code == 1) {
          ElMessage.success('设置成功')
        } else {
          ElMessage('设置失败')
        }
      })
    },
  //   get(){
 
   },
   mounted(){
  //     exceptionApi.analysisdata('金山区金山新城JSC1-0401单元1-11-01地块项目09','2023-07-01 00:00:00','2023-07-03 00:00:00').then((res)=>{
  //       this.a = res.data.data
  //       // console.log('数据为:',res.data.data);
  //       return res.data.data
  //     }).then(result =>{
  //       console.log('链:',result);
  //       exceptionApi.analysisdata('上海国林建材有限公司','2023-07-01 00:00:00','2023-07-03 00:00:00')
  //     }
  //     )
  //   },
   },
   methods:{
    doThing(){
      this.store.increment(5)
      this.store.doubleCount
    }
   }
  //  async getAll(){
  //    const a = await this.$http
  //       .get('/dust/sitenamecode', {
  //         params: {
  //           exceptionType: '0',
  //           beginTime: this.beginTime,
  //           endTime: this.endTime
  //         }
  //       }).then((result) => {
  //         this.exception.exception0 = result.data.data
  //       })
  //       const b = await this.$http
  //       .get('/dust/sitenamecode', {
  //         params: {
  //           exceptionType: '1',
  //           beginTime: this.beginTime,
  //           endTime: this.endTime
  //         }
  //       }).then((result) => {
  //         this.exception.exception1 = result.data.data
  //       })
  //       const c = await this.$http
  //       .get('/dust/sitenamecode', {
  //         params: {
  //           exceptionType: '2',
  //           beginTime: this.beginTime,
  //           endTime: this.endTime
  //         }
  //       }).then((result) => {
  //         this.exception.exception2 = result.data.data
  //       })
  //       const d = await this.$http
  //       .get('/dust/sitenamecode', {
  //         params: {
  //           exceptionType: '3',
  //           beginTime: this.beginTime,
  //           endTime: this.endTime
  //         }
  //       }).then((result) => {
  //         this.exception.exception3 = result.data.data
  //       })
  //      console.log('外1:',this.exception.exception0);
  //      console.log('外2:',this.exception.exception1);
  //      console.log('外3:',this.exception.exception2);
  //      console.log('外4:',this.exception.exception3);
  //       // Promise.all([a,b,c,d,e,f,g,h]).then((responses)=>{
  //       //   console.log('全部数据为:');
  //       //   for (const response of responses) {
  //       //     console.log('数据:',response.data.data);
  //       // }
  //       // })
  //   }
  }
}
</script>
<template>
  <div>
    <el-button type="primary" @click="doThing">点击{{ store.doubleCount }}</el-button>
  </div>
  <div>{{ a }}</div>
  <div>{{ store.secret }}</div>
  <div>{{ store.vue }}</div>
  <div>{{ store.天 }}</div>
  <el-card>
  <el-form>
    <div>生成配置文件</div>
    <el-form-item label="区域:">
      <el-radio-group v-model="radio">
        <el-radio :label="0">金山</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item>
      <TimeSelectWithShortCuts @submit-time="giveTime"></TimeSelectWithShortCuts>
    </el-form-item>
    <el-form-item label="是否定时:">
      <el-radio-group v-model="radio1">
        <el-radio label="1" size="large">是</el-radio>
        <el-radio label="2" size="large">否</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item> <el-button type="success" @click="set">设置</el-button></el-form-item>
  </el-form>
  <correct theme="outline" size="24" fill="#333"/>
</el-card>
</template>
<style scoped>
</style>
<style scoped>
.el-card {
  margin: 10px;
}
div {
  margin-bottom: 10px;
  color: #333333;
}
:deep(.el-form-item__label) {
  font-weight: bold;
  font-size: 16px;
  color: #333333;
}
</style>