xiongchao 3 سال پیش
والد
کامیت
07ee53f0ff

+ 206 - 0
public/base.js

@@ -0,0 +1,206 @@
+const ACCESS_TOKEN = 'Access-Token'
+const VUE_STORE_BASE = 'pro__'
+/**
+ * 元换算为万元
+ * @param num :
+ * @returns {number} :
+ */
+function divTenThousand (num) {
+  if (num == null) {
+    return 0
+  }
+  return div(num, 10000, 3)
+  // return num
+}
+
+/**
+ * 元换算为万元
+ * @param num :
+ * @returns {RegExpMatchArray} :
+ */
+function divScale (num) {
+  if (num == null) {
+    return 0
+  }
+  const str = Number(Math.round(num * 100) / 100).toString()
+  if (str.indexOf('.') > 0) {
+    return (str + '00').match(/^\d+(?:\.\d{0,2})?/)
+  }
+  return str + '.00'
+  // return num
+}
+
+/**
+ * 元换算为万元,并格式化
+ * @param num :
+ * @returns {string} :
+ */
+// eslint-disable-next-line no-unused-vars
+function divTenThousandFormatter (num) {
+  return formatter(divTenThousand(num))
+}
+
+function formatter (value) {
+  if (value == null) {
+    return value
+  }
+  return value.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
+}
+
+// eslint-disable-next-line no-unused-vars
+function parser (value) {
+  return value.replace(/\$\s?|(,*)/g, '')
+}
+
+/**
+ * 万元换算为元
+ * @param num
+ * @returns {*}
+ */
+// eslint-disable-next-line no-unused-vars
+function mulTenThousand (num) {
+  if (num == null || num === '') {
+    return 0
+  }
+  return mul(num, 10000, 6)
+  // return num
+}
+
+// eslint-disable-next-line no-unused-vars
+function add (arg1, arg2) {
+  if (arg1 == null || arg1 === '') {
+    arg1 = 0
+  }
+  if (arg2 == null || arg2 === '') {
+    arg2 = 0
+  }
+  let r1, r2
+  try {
+    r1 = arg1.toString().split('.')[1].length
+  } catch (e) {
+    r1 = 0
+  }
+  try {
+    r2 = arg2.toString().split('.')[1].length
+  } catch (e) {
+    r2 = 0
+  }
+  const m = Math.pow(10, Math.max(r1, r2))
+  const n = (r1 >= r2) ? r1 : r2
+  return ((arg1 * m + arg2 * m) / m).toFixed(n)
+}
+
+// eslint-disable-next-line no-unused-vars
+function sub (arg1, arg2) {
+  if (arg1 == null || arg1 === '') {
+    arg1 = 0
+  }
+  if (arg2 == null || arg2 === '') {
+    arg2 = 0
+  }
+  let re1, re2
+  try {
+    re1 = arg1.toString().split('.')[1].length
+  } catch (e) {
+    re1 = 0
+  }
+  try {
+    re2 = arg2.toString().split('.')[1].length
+  } catch (e) {
+    re2 = 0
+  }
+  const m = Math.pow(10, Math.max(re1, re2))
+  const n = (re1 >= re2) ? re1 : re2
+  return ((arg1 * m - arg2 * m) / m).toFixed(n)
+}
+
+/**
+ * 1
+ * @param arg1
+ * @param arg2
+ * @returns {number}
+ */
+// eslint-disable-next-line no-unused-vars
+function mul (arg1, arg2) {
+  if (arg1 == null || arg1 === '') {
+    arg1 = 0
+  }
+  if (arg2 == null || arg2 === '') {
+    arg2 = 0
+  }
+  let m = 0
+  const s1 = arg1.toString()
+  const s2 = arg2.toString()
+  try {
+    m += s1.split('.')[1].length
+  } catch (e) {}
+  try {
+    m += s2.split('.')[1].length
+  } catch (e) {}
+
+  return Number(s1.replace('.', '')) * Number(s2.replace('.', '')) / Math.pow(10, m)
+}
+/**
+ * 除法 注意如果整除了 小数点将无效
+ * @param arg1 : 被除数
+ * @param arg2 : 除数
+ * @param digit :精确位数
+ * @returns {number}
+ */
+function div (arg1, arg2, digit) {
+  if (arg1 == null || arg1 === '') {
+    arg1 = 0
+  }
+  if (arg2 == null || arg2 === '') {
+    arg2 = 1
+  }
+  let t1 = 0
+  let t2 = 0
+  try { t1 = arg1.toString().split('.')[1].length } catch (e) {}
+  try { t2 = arg2.toString().split('.')[1].length } catch (e) {}
+  const r1 = Number(arg1.toString().replace('.', ''))
+  const r2 = Number(arg2.toString().replace('.', ''))
+  // 获取小数点后的计算值
+  const result = ((r1 / r2) * Math.pow(10, t2 - t1)).toString()
+  let result2 = result.split('.')[1]
+  if (result2 !== undefined) {
+    result2 = result2.substring(0, digit > result2.length ? result2.length : digit)
+  } else {
+    result2 = ''
+  }
+  while (result2.length < digit) {
+    result2 = result2 + '0'
+  }
+  if (digit === 0) {
+    return Number(result.split('.')[0])
+  }
+  return Number(result.split('.')[0] + '.' + result2)
+}
+
+/**
+ * 获取vue token
+ * @returns {string}
+ */
+function getToken () {
+  const storeTokenJson = JSON.parse(localStorage.getItem(VUE_STORE_BASE + ACCESS_TOKEN))
+  return 'Bearer ' + storeTokenJson.value
+}
+
+function getHeader () {
+  return {
+    Authorization: getToken(),
+    accept: 'application/json; charset=utf-8',
+    'Access-Control-Allow-Origin': 'http://localhost:5000',
+    'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept',
+    'Content-Type': 'application/json;charset=UTF-8'
+  }
+}
+
+function ajaxError (xhr) {
+  if (xhr.status === 401) {
+    // 跳转登录页面
+    window.parent.location.href = '/user/login'
+  } else {
+    console.log('请求错误')
+  }
+}

+ 28 - 0
public/big-screen/static/common/base.js

@@ -175,3 +175,31 @@ function div (arg1, arg2, digit) {
   }
   return Number(result.split('.')[0] + '.' + result2)
 }
+
+/**
+ * 获取vue token
+ * @returns {string}
+ */
+function getToken () {
+  const storeTokenJson = JSON.parse(localStorage.getItem(VUE_STORE_BASE + ACCESS_TOKEN))
+  return 'Bearer ' + storeTokenJson.value
+}
+
+function getHeader () {
+  return {
+    Authorization: getToken()
+    // accept: "application/json; charset=utf-8",
+    // "Access-Control-Allow-Origin": "http://localhost:5000",
+    // "Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept"
+  }
+}
+
+function ajaxError (xhr) {
+  if (xhr.status === 401) {
+    // 跳转登录页面
+    window.parent.location.href = '/user/login'
+  } else {
+    // 调用外部的error
+    error && error(xhr, textStatus, errorThrown)
+  }
+}

+ 1 - 0
public/tui-calendar/example00-basic.html

@@ -115,6 +115,7 @@
     <script src="https://uicdn.toast.com/tui.date-picker/v4.0.3/tui-date-picker.min.js"></script>
     <script src='js/moment-2.20.1.min.js'></script>
     <script src='js/chance-1.0.13.min.js'></script>
+    <script src="../base.js"></script>
     <script src="./dist/tui-calendar.js"></script>
     <script src="./js/data/calendars.js"></script>
     <script src="./js/data/schedules.js"></script>

+ 25 - 0
public/tui-calendar/js/app.js

@@ -54,6 +54,8 @@
                 changes.category = 'time';
             }
 
+            // 调用ajax更新日期
+            changeCheckJobDate(schedule, changes);
             cal.updateSchedule(schedule.id, schedule.calendarId, changes);
             refreshScheduleVisibility();
         },
@@ -333,6 +335,29 @@
         refreshScheduleVisibility();
     }
 
+    // 更新日历图
+    function changeCheckJobDate(schedule, changes) {
+      // 处理日期Tue Sep 14 2021 00:00:00, Tue Sep 14 2021 23:59:59
+      const startTime = moment(new Date(changes.start)).format("YYYY-MM-DD")
+      const endTime = moment(new Date(changes.end)).format("YYYY-MM-DD")
+      console.log(startTime)
+      console.log(endTime)
+      $.ajax({
+        type: "put",
+        url: '/api/check/jobs/' + schedule.id,
+        method: 'PUT',
+        data: JSON.stringify({ id:schedule.id, startTime: startTime, endTime: endTime }),
+        dataType: 'json',
+        headers: getHeader(),
+        success: function (response) {
+          alert("执行日期更新成功")
+        },
+        error: function (xhr,textStatus,errorThrown) {
+          ajaxError(xhr);
+        }
+      });
+    }
+
     function refreshScheduleVisibility() {
         var calendarElements = Array.prototype.slice.call(document.querySelectorAll('#calendarList input'));
 

+ 2 - 2
public/tui-calendar/js/data/calendars.js

@@ -55,7 +55,7 @@ function hexToRGBA (hex) {
       calendar.borderColor = cList[i].borderColor
       addCalendar(calendar)
     }
-    /*var calendar
+    /* var calendar
     var id = 0
 
     calendar = new CalendarInfo()
@@ -136,6 +136,6 @@ function hexToRGBA (hex) {
     calendar.bgColor = '#ff4040'
     calendar.dragBgColor = '#ff4040'
     calendar.borderColor = '#ff4040'
-    addCalendar(calendar)*/
+    addCalendar(calendar) */
   }
 })()

+ 1 - 1
src/permission.js

@@ -12,7 +12,7 @@ import { GlobalConstant } from '@/constant'
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
-const whiteList = ['login', 'register', 'registerResult', GlobalConstant.SINGLE_LOGIN_ROUTER_NAME] // no redirect whitelist
+const whiteList = ['login', 'register', 'test', 'registerResult', GlobalConstant.SINGLE_LOGIN_ROUTER_NAME] // no redirect whitelist
 
 router.beforeEach((to, from, next) => {
   if (to.path === GlobalConstant.PC_INDEX_PATH) {

+ 1 - 0
src/views/check/checkjob/modules/Detail.vue

@@ -58,6 +58,7 @@
     </detail-list>
     <title-divider title="任务信息" width="90px"></title-divider>
     <detail-list title="" :col="3">
+      <detail-list-item term="执行人">{{ model.checkUserName }}</detail-list-item>
       <detail-list-item term="实际工时">{{ model.realHours }}</detail-list-item>
       <detail-list-item term="执行日期">{{ model.startTime }}</detail-list-item>
       <detail-list-item term="截至日期">{{ model.endTime }}</detail-list-item>

+ 16 - 0
src/views/check/checkjob/modules/DetailSbCheckJob.vue

@@ -40,6 +40,17 @@
           :value="parseInt(value)">{{ label }}
         </a-select-option>
       </a-select>
+      <a-select
+        style="margin-left: 8px;width:100px;"
+        @change="levelChange"
+        placeholder="请选择">
+        <a-select-option
+          v-for="(label,value) in standardLevelMap"
+          :key="value"
+          :label="label"
+          :value="parseInt(value)">{{ label }}
+        </a-select-option>
+      </a-select>
     </div>
     <a-table
       :data-source="data"
@@ -321,6 +332,11 @@ export default {
       queryCheckJob({ sbId: this.model.id, type: this.checkType, status: value }).then(res => {
         this.data = res.data
       })
+    },
+    levelChange (value) {
+      queryCheckJob({ sbId: this.model.id, type: this.checkType, level: value }).then(res => {
+        this.data = res.data
+      })
     }
   }
 }

+ 2 - 1
src/views/test/BaseFormBak.vue

@@ -397,7 +397,7 @@ export default {
           values.id = result
           values.param4 = this.BaseTool.Date.formatter(values.param4, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
           this.data.push(values)
-          this.$message.info('新成功')
+          this.$message.info('新成功')
           this.confirmLoading = false
         } else {
           const data = [...this.data]
@@ -408,6 +408,7 @@ export default {
           for (var i = length; i > 0; --i) { result += str[Math.floor(Math.random() * str.length)] }
           values.id = result
           this.data.push(values)
+          this.$message.info('更新成功')
         }
         localStorage.setItem('test', JSON.stringify(this.data))
         this.form.resetFields()