347617796@qq.com преди 3 години
родител
ревизия
c967f54d0a
променени са 3 файла, в които са добавени 95 реда и са изтрити 15 реда
  1. 33 0
      src/api/auth.js
  2. 4 1
      src/views/set/buy.vue
  3. 58 14
      src/views/set/log.vue

+ 33 - 0
src/api/auth.js

@@ -2,6 +2,39 @@ const TokenKey = 'A-Token'
 const UserIdKey = 'userData'
 const TypesKey = 'types'
 import Vue from 'vue'
+
+
+function getClass(o) { //判断数据类型
+    return Object.prototype.toString.call(o).slice(8, -1);
+}
+
+function deepCopy(obj) {//深度拷贝对象
+    var result, oClass = getClass(obj);
+    if (oClass == "Object") result = {}; //判断传入的如果是对象,继续遍历
+    else if (oClass == "Array") result = []; //判断传入的如果是数组,继续遍历
+    else return obj; //如果是基本数据类型就直接返回
+    for (var i in obj) {
+        var copy = obj[i];
+        if (getClass(copy) == "Object"||getClass(copy) == "Array") result[i] = deepCopy(copy); //递归方法 ,如果对象继续变量obj[i],下一级还是对象,就obj[i][i]
+        // else if (getClass(copy) == "Array") result[i] = deepCopy(copy); //递归方法 ,如果对象继续数组obj[i],下一级还是数组,就obj[i][i]
+        else result[i] = copy; //基本数据类型则赋值给属性
+    }
+    return result;
+}
+let data={
+	name:'div',
+	colro:['red','green'],
+	childer:{
+		name:'span',
+		colro:'red',
+		content:['哈哈','喜喜']
+	}
+}
+
+let data2=deepCopy(data)
+console.log(data2)
+
+
 export function openError(data) {
     if(process.env.NODE_ENV=='production'){
           Vue.prototype.$axios('post','/api/e',data)

+ 4 - 1
src/views/set/buy.vue

@@ -27,7 +27,10 @@ export default {
 	watch:{
 	},
 	mounted() {
-		this.init();
+		let s={'name':'喜喜',age:'18'}
+		let arr=Object.create(s);
+		// arr.name='喜喜2';
+		console.log(s,arr)
 	},
 	methods: {
 		init() {

+ 58 - 14
src/views/set/log.vue

@@ -10,7 +10,8 @@
 					<br />
 					3、日志支持每月、每周、每次汇报,可自行根据需要设置“日志积分规则
 				</div>
-				<div class="flex-box-end" style="margin-top: 20px;">	
+				<div class="flex-box-end" style="margin-top: 20px;">
+					<el-button v-if="$authoritys() != 'dept_manager' && $authoritys() != 'employee'" type="primary" @click="isShowLog = true">刷新汇报记录</el-button>
 					<el-button size="small" plain @click="add()">添加日志模板</el-button>
 				</div>
 			</div>
@@ -31,7 +32,6 @@
 				<el-table-column label="操作">
 					<template slot-scope="scope">
 						<div class="flex-box-ce">
-							<div class="blue" @click="refresh(scope.row)" style="margin-right: 10px;cursor: pointer;">刷新汇报记录</div>
 							<div @click.stop="openSet(scope.row)" style="margin-right: 10px;"><span class="lookQrcode">编辑</span></div>
 							<div @click.stop="deleteSet(scope.row)"><span class="lookQrcode red">删除</span></div>
 						</div>
@@ -111,6 +111,22 @@
 				</el-form-item>
 			</el-form>
 		</el-dialog>
+		<el-dialog title="刷新日志记录" :visible.sync="isShowLog" top="25vh" width="520px" class="dialog" :close-on-click-modal="false" :close-on-press-escape="false">
+			<el-form :model="logData" ref="setForm2" label-width="110px">
+				<el-form-item label="日志汇报要求" prop="type" :rules="[{ required: true, message: '请选择汇报要求' }]">
+					<el-select class="widthInput" v-model="logData.type" placeholder="请选择" style="width: 250px;">
+						<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
+					</el-select>
+				</el-form-item>
+				<el-form-item label="选择日期" prop="target_date" :rules="[{ required: true, message: '请选择汇报要求' }]">
+					<el-date-picker :picker-options="pickerOptions" v-model="logData.target_date" type="date" value-format="yyyy-MM-dd" placeholder="选择日期" style="width: 250px;"></el-date-picker>
+				</el-form-item>
+			</el-form>
+			<span slot="footer" class="dialog-footer">
+				<el-button @click="isShowLog = false">取 消</el-button>
+				<el-button type="primary" @click="refresh('setForm2')">确 定</el-button>
+			</span>
+		</el-dialog>
 	</div>
 </template>
 
@@ -125,6 +141,11 @@ export default {
 			ding_enable: true,
 			list: [],
 			dialogVisible: false,
+			pickerOptions: {
+				disabledDate(time) {
+					return time.getTime() > Date.now() - 8.64e7;
+				}
+			},
 			selectItem: {
 				config: { point: 0, upper_limit: 0 },
 				enable: true,
@@ -152,7 +173,13 @@ export default {
 			nameVal: '',
 
 			// 添加模板
-			isAdd: false
+			isAdd: false,
+
+			isShowLog: false,
+			logData: {
+				type: 1,
+				target_date: ''
+			}
 		};
 	},
 	watch: {
@@ -175,18 +202,35 @@ export default {
 		this.getList();
 	},
 	methods: {
-		refresh() {
-			this.$axios('post', '/api/ding/report_sync', data)
-				.then(res => {
-					if (res.data.code == 1) {
-						this.$message.success(res.data.msg);
-						this.getList();
-						this.dialogVisible = false;
+		refresh(fromName) {
+			this.$refs[fromName].validate(valid => {
+				if (valid) {
+					let type='';
+					if(this.logData.type==1){
+						type='daily'
+					}else if(this.logData.type==2){
+						type='weekly'
+					}else{
+						type='monthly'
 					}
-				})
-				.finally(() => {
-					this.setLoading = false;
-				});
+					let data = {
+						type: type,
+						employee_id: this.$getUserData().id,
+						target_date: this.logData.target_date
+					};
+					this.$axios('post', '/api/ding/report_sync', data)
+						.then(res => {
+							this.$message.success('已刷新');
+						})
+						.finally(() => {
+							this.logData={
+								type: 1,
+								target_date: ''
+							};
+							this.isShowLog = false;
+						});
+				}
+			});
 		},
 		deleteSet(e) {
 			this.$confirm('确定要删除该日志模板吗?', '提示', {