10 changed files with 1566 additions and 974 deletions
@ -1,173 +0,0 @@
|
||||
"use strict"; |
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { |
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; |
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); |
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; |
||||
return c > 3 && r && Object.defineProperty(target, key, r), r; |
||||
}; |
||||
var __param = (this && this.__param) || function (paramIndex, decorator) { |
||||
return function (target, key) { decorator(target, key, paramIndex); } |
||||
}; |
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
||||
return new (P || (P = Promise))(function (resolve, reject) { |
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
||||
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
||||
}); |
||||
}; |
||||
var __generator = (this && this.__generator) || function (thisArg, body) { |
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
||||
function verb(n) { return function (v) { return step([n, v]); }; } |
||||
function step(op) { |
||||
if (f) throw new TypeError("Generator is already executing."); |
||||
while (_) try { |
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
||||
if (y = 0, t) op = [op[0] & 2, t.value]; |
||||
switch (op[0]) { |
||||
case 0: case 1: t = op; break; |
||||
case 4: _.label++; return { value: op[1], done: false }; |
||||
case 5: _.label++; y = op[1]; op = [0]; continue; |
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue; |
||||
default: |
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
||||
if (t[2]) _.ops.pop(); |
||||
_.trys.pop(); continue; |
||||
} |
||||
op = body.call(thisArg, _); |
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
||||
} |
||||
}; |
||||
exports.__esModule = true; |
||||
exports.ChatWindowComponent = void 0; |
||||
var core_1 = require("@angular/core"); |
||||
var signalRChat_1 = require("../../../../signalRChat"); |
||||
var station_weekly_plan_component_1 = require("../../task/station-weekly-plan/station-weekly-plan.component"); |
||||
var station_task_execution_component_1 = require("../../task/station-task-execution/station-task-execution.component"); |
||||
var ChatWindowComponent = /** @class */ (function () { |
||||
function ChatWindowComponent(ngZone, element, message, parentComponent, http, parentComponent2) { |
||||
this.ngZone = ngZone; |
||||
this.element = element; |
||||
this.message = message; |
||||
this.parentComponent = parentComponent; |
||||
this.http = http; |
||||
this.parentComponent2 = parentComponent2; |
||||
/** |
||||
* 消息列表 |
||||
*/ |
||||
this.members = []; |
||||
this.MessagesList = []; |
||||
this.isLoading = false; |
||||
this.chatName = ''; |
||||
this.text = ''; |
||||
} |
||||
ChatWindowComponent.prototype.ngOnInit = function () { |
||||
return __awaiter(this, void 0, Promise, function () { |
||||
var _this = this; |
||||
return __generator(this, function (_a) { |
||||
switch (_a.label) { |
||||
case 0: |
||||
this.userId = JSON.parse(sessionStorage.getItem('userData')).id; |
||||
this.userName = JSON.parse(sessionStorage.getItem('userData')).name; |
||||
this.chatcontent = this.element.nativeElement.querySelector("#chatcontent"); |
||||
setTimeout(function () { |
||||
_this.scrollToBottom(); |
||||
}, 0); |
||||
return [4 /*yield*/, signalRChat_1["default"].initSR(this.taskId)]; |
||||
case 1: |
||||
_a.sent(); |
||||
return [4 /*yield*/, this.getAllMessages()]; |
||||
case 2: |
||||
_a.sent(); |
||||
// 接收来自中心的消息
|
||||
signalRChat_1["default"].SR.on('receiveMessage', function (message) { |
||||
console.log('收到消息', message); |
||||
_this.MessagesList.push(message); |
||||
if (_this.chatcontent.scrollHeight - (_this.chatcontent.scrollTop + _this.chatcontent.clientHeight) == 0) { |
||||
setTimeout(function () { |
||||
_this.scrollToBottom(); |
||||
}, 0); |
||||
} |
||||
}); |
||||
return [2 /*return*/]; |
||||
} |
||||
}); |
||||
}); |
||||
}; |
||||
/** |
||||
* 获得所有消息 |
||||
*/ |
||||
ChatWindowComponent.prototype.getAllMessages = function () { |
||||
return __awaiter(this, void 0, void 0, function () { |
||||
var _this = this; |
||||
return __generator(this, function (_a) { |
||||
this.isLoading = true; |
||||
console.log('任务id', this.taskId); |
||||
console.log('this', this); |
||||
try { |
||||
this.http.get("/api/TaskChats/Groups/" + this.taskId).subscribe(function (data) { |
||||
_this.MessagesList = data.taskChatMessages || []; |
||||
_this.members = data.members || []; |
||||
_this.members.forEach(function (item) { |
||||
_this.chatName += item.name + ' '; |
||||
}); |
||||
_this.chatName = _this.chatName + '的群聊' + '(' + _this.members.length + ')'; |
||||
_this.isLoading = false; |
||||
console.log('chatName', _this.chatName); |
||||
console.log('消息列表', _this.MessagesList); |
||||
setTimeout(function () { |
||||
_this.scrollToBottom(); |
||||
}, 0); |
||||
}); |
||||
} |
||||
catch (error) { |
||||
console.log(error); |
||||
} |
||||
return [2 /*return*/]; |
||||
}); |
||||
}); |
||||
}; |
||||
ChatWindowComponent.prototype.ngOnDestroy = function () { |
||||
signalRChat_1["default"].stopSR(); |
||||
}; |
||||
ChatWindowComponent.prototype.close = function () { |
||||
this.parentComponent.closechat(); |
||||
this.parentComponent2.closechat(); |
||||
}; |
||||
ChatWindowComponent.prototype.send = function () { |
||||
var _this = this; |
||||
if (!this.text) { |
||||
this.message.create('warning', '输入不能为空'); |
||||
return; |
||||
} |
||||
// 发送消息
|
||||
signalRChat_1["default"].SR.send('sendMessage', this.taskId, this.text); |
||||
setTimeout(function () { |
||||
_this.scrollToBottom(); |
||||
_this.text = ''; |
||||
}, 0); |
||||
}; |
||||
ChatWindowComponent.prototype.scrollToBottom = function () { |
||||
this.chatcontent.scrollTop = this.chatcontent.scrollHeight; |
||||
}; |
||||
__decorate([ |
||||
core_1.Input() |
||||
], ChatWindowComponent.prototype, "taskId"); |
||||
ChatWindowComponent = __decorate([ |
||||
core_1.Component({ |
||||
selector: 'app-chat-window', |
||||
templateUrl: './chat-window.component.html', |
||||
styleUrls: ['./chat-window.component.scss'] |
||||
}), |
||||
__param(3, core_1.Inject(station_weekly_plan_component_1.StationWeeklyPlanComponent)), |
||||
__param(5, core_1.Inject(station_task_execution_component_1.StationTaskExecutionComponent)) |
||||
], ChatWindowComponent); |
||||
return ChatWindowComponent; |
||||
}()); |
||||
exports.ChatWindowComponent = ChatWindowComponent; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,36 @@
|
||||
.bigbox { |
||||
width: 100%; |
||||
height: 100%; |
||||
display: flex; |
||||
flex-direction: column; |
||||
} |
||||
|
||||
.btnbox { |
||||
height: 62px; |
||||
line-height: 62px; |
||||
position: relative; |
||||
.goback{ |
||||
position: absolute; |
||||
left: 18px; |
||||
top: 15px; |
||||
} |
||||
button { |
||||
margin: 0 6px; |
||||
} |
||||
|
||||
border-bottom: 1px dashed gray; |
||||
} |
||||
|
||||
.box { |
||||
width: 100%; |
||||
flex: 1; |
||||
overflow-y: auto; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: center; |
||||
|
||||
#tablebox, |
||||
#tablebox2 { |
||||
margin-bottom: 16px; |
||||
} |
||||
} |
@ -0,0 +1,61 @@
|
||||
import { Component, OnInit } from '@angular/core'; |
||||
import { ActivatedRoute } from '@angular/router'; |
||||
import { MethodService } from 'src/app/service/method.service'; |
||||
declare var $: any |
||||
@Component({ |
||||
selector: 'app-task-details', |
||||
templateUrl: './task-details.component.html', |
||||
styleUrls: ['./task-details.component.scss'] |
||||
}) |
||||
export class TaskDetailsPagesComponent implements OnInit { |
||||
|
||||
constructor(public methodService: MethodService, private route: ActivatedRoute) { } |
||||
|
||||
|
||||
/** |
||||
* 实战演练表格信息 |
||||
*/ |
||||
exerciseData: any = { |
||||
data: { |
||||
add: '', |
||||
data: { |
||||
form: [] |
||||
}, |
||||
index: 2, |
||||
information: "", |
||||
people: "", |
||||
situation: "", |
||||
time: "请选择时间", |
||||
typeAndAmount: "", |
||||
vehicleType: [] |
||||
} |
||||
} |
||||
/** |
||||
* 救援预案信息 |
||||
*/ |
||||
planData: any |
||||
|
||||
|
||||
|
||||
ngOnInit(): void { |
||||
let taskId = this.route.snapshot.queryParams.id |
||||
this.methodService.getTaskDetails(taskId).then((data: any) => { |
||||
let obj = JSON.parse(data.resultData) |
||||
this.exerciseData = this.methodService.getTaskDetailsItem('实战演练', obj.form) |
||||
console.log('实战演练详情', this.exerciseData) |
||||
this.planData = this.methodService.getTaskDetailsItem('数字化预案', obj.form) |
||||
}) |
||||
|
||||
} |
||||
|
||||
|
||||
goback() { |
||||
window.history.back() |
||||
} |
||||
|
||||
xxx = true |
||||
yyy = [1] |
||||
download(type) { |
||||
type == 1 ? $("#tablebox").wordExport('演练卡') : $("#tablebox2").wordExport('数字化预案'); |
||||
} |
||||
} |
@ -1,714 +0,0 @@
|
||||
"use strict"; |
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { |
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; |
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); |
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; |
||||
return c > 3 && r && Object.defineProperty(target, key, r), r; |
||||
}; |
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
||||
return new (P || (P = Promise))(function (resolve, reject) { |
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
||||
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
||||
}); |
||||
}; |
||||
var __generator = (this && this.__generator) || function (thisArg, body) { |
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
||||
function verb(n) { return function (v) { return step([n, v]); }; } |
||||
function step(op) { |
||||
if (f) throw new TypeError("Generator is already executing."); |
||||
while (_) try { |
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
||||
if (y = 0, t) op = [op[0] & 2, t.value]; |
||||
switch (op[0]) { |
||||
case 0: case 1: t = op; break; |
||||
case 4: _.label++; return { value: op[1], done: false }; |
||||
case 5: _.label++; y = op[1]; op = [0]; continue; |
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue; |
||||
default: |
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
||||
if (t[2]) _.ops.pop(); |
||||
_.trys.pop(); continue; |
||||
} |
||||
op = body.call(thisArg, _); |
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
||||
} |
||||
}; |
||||
exports.__esModule = true; |
||||
exports.StationWeeklyPlanComponent = void 0; |
||||
var core_1 = require("@angular/core"); |
||||
var moment = require("moment"); |
||||
var task_details_component_1 = require("./task-details/task-details.component"); |
||||
var create_task_component_1 = require("./create-task/create-task.component"); |
||||
var date_fns_1 = require("date-fns"); |
||||
var plan_adjustment_component_1 = require("../da-oneself-plan/plan-adjustment/plan-adjustment.component"); |
||||
var StationWeeklyPlanComponent = /** @class */ (function () { |
||||
function StationWeeklyPlanComponent(http, modal, message, viewContainerRef, methodService, newTaskMessage) { |
||||
var _this = this; |
||||
this.http = http; |
||||
this.modal = modal; |
||||
this.message = message; |
||||
this.viewContainerRef = viewContainerRef; |
||||
this.methodService = methodService; |
||||
this.newTaskMessage = newTaskMessage; |
||||
this.today = new Date(); |
||||
this.disabledDate = function (current) { return date_fns_1.differenceInCalendarDays(current, _this.today) <= 0; }; |
||||
this.months = [ |
||||
{ id: 1, name: '1月', isable: true }, |
||||
{ id: 2, name: '2月', isable: true }, |
||||
{ id: 3, name: '3月', isable: true }, |
||||
{ id: 4, name: '4月', isable: true }, |
||||
{ id: 5, name: '5月', isable: true }, |
||||
{ id: 6, name: '6月', isable: true }, |
||||
{ id: 7, name: '7月', isable: true }, |
||||
{ id: 8, name: '8月', isable: true }, |
||||
{ id: 9, name: '9月', isable: true }, |
||||
{ id: 10, name: '10月', isable: true }, |
||||
{ id: 11, name: '11月', isable: true }, |
||||
{ id: 12, name: '12月', isable: true } |
||||
]; |
||||
this.selectedYear = 2022; |
||||
//当月有几个周二周四
|
||||
this.TuesdayThursdayNum = 0; |
||||
this.isExpand = true; |
||||
this.formatOne = function (percent) { return percent + "%\n\u5B8C\u6210\u7387"; }; |
||||
this.cardData = [ |
||||
{ name: '双随机', badgeNum: 0, isDetails: false, isLoading: false, background: '#1D9DFF', icon: 'suiji.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '行政许可', badgeNum: 0, isDetails: false, isLoading: false, background: '#42B983', icon: 'xuke.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '熟悉演练', badgeNum: 0, isDetails: false, isLoading: false, background: '#9D80FF', icon: 'yanlian.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '联络指导', badgeNum: 0, isDetails: false, isLoading: false, background: '#5483EA', icon: 'zhidao.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '消防宣传', badgeNum: 0, isDetails: false, isLoading: false, background: '#FF5D2A', icon: 'xuanchuan.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '投诉举报', badgeNum: 0, isDetails: false, isLoading: false, background: '#5087FF', icon: 'tousu.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '火灾调查', badgeNum: 0, isDetails: false, isLoading: false, background: '#FF404D', icon: 'huozai.png', passed: 0, inspected: 0, percentage: 0, data: [] } |
||||
]; |
||||
this.isLoading = false; |
||||
this.PageNumber = 1; |
||||
this.PageSize = 9999; |
||||
this.stationData = [ |
||||
{ name: '', isExpand: true, isLoading: false, data: [], allUnitsNum: 0, awaitInspect: 0, inspected: 0, percentage: 0 } |
||||
]; |
||||
this.ischat = false; |
||||
} |
||||
StationWeeklyPlanComponent.prototype.selectMonth = function (item) { |
||||
this.selectedMonth = item.id; |
||||
this.initializeData(); |
||||
this.getTuesdayThursdayNum(); |
||||
this.getTaskList(); |
||||
this.getTaskListPass(this.stationData[0]); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.selectYear = function (e) { |
||||
this.selectedYear = e; |
||||
this.initializeData(); |
||||
this.getTuesdayThursdayNum(); |
||||
this.getTaskList(); |
||||
this.getTaskListPass(this.stationData[0]); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.getTuesdayThursdayNum = function () { |
||||
var _this = this; |
||||
var selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'; |
||||
this.http.get("/api/TaskTargets/GetTargetCount/" + selectedTime).subscribe(function (data) { |
||||
console.log('最大日期', data); |
||||
_this.TuesdayThursdayNum = data; |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.expand = function () { |
||||
this.isExpand = !this.isExpand; |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.openDetails = function (data, type) { |
||||
data.isDetails = type; |
||||
data.badgeNum = 0; |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.radioChange = function (e, i, element) { |
||||
var _this = this; |
||||
element.isLoading = true; |
||||
var body = { |
||||
isSpread: e |
||||
}; |
||||
this.http.patch("/api/PlanTasks/" + i.id, body).subscribe({ |
||||
next: function (data) { |
||||
_this.message.create('success', e ? '宣传通知已发出' : '取消宣传'); |
||||
element.isLoading = false; |
||||
}, |
||||
error: function (err) { |
||||
_this.message.create('warning', '发送失败'); |
||||
element.isLoading = false; |
||||
} |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.checkTime = function (e, i, element) { |
||||
var _this = this; |
||||
if (e) { |
||||
i.planTime = moment(e).format('yyyy-MM-DD'); |
||||
} |
||||
else { |
||||
i.planTime = null; |
||||
} |
||||
element.isLoading = true; |
||||
var body = { |
||||
planTime: i.planTime |
||||
}; |
||||
this.http.patch("/api/PlanTasks/" + i.id, body).subscribe({ |
||||
next: function (data) { |
||||
_this.message.create('success', '检查日期分配成功'); |
||||
element.isLoading = false; |
||||
}, |
||||
error: function (err) { |
||||
_this.message.create('warning', '检查日期分配失败'); |
||||
element.isLoading = false; |
||||
} |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.getAllStation = function () { |
||||
var _this = this; |
||||
var params = { |
||||
ContainsChildren: true, |
||||
pageSize: 9999 |
||||
}; |
||||
this.http.get('/api/Organizations', { |
||||
params: params |
||||
}).subscribe(function (data) { |
||||
_this.totalCount = data.totalCount; |
||||
data.items = data.items.filter(function (element) { |
||||
return element.level == 'squadron'; |
||||
}); |
||||
data.items.forEach(function (element) { |
||||
element.isExpand = false; |
||||
element.isLoading = false; |
||||
}); |
||||
_this.stationData = data.items; |
||||
}); |
||||
}; |
||||
//初始化数据
|
||||
StationWeeklyPlanComponent.prototype.initializeData = function () { |
||||
this.cardData = [ |
||||
{ name: '双随机', badgeNum: 0, isDetails: false, isLoading: false, background: '#1D9DFF', icon: 'suiji.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '行政许可', badgeNum: 0, isDetails: false, isLoading: false, background: '#42B983', icon: 'xuke.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '熟悉演练', badgeNum: 0, isDetails: false, isLoading: false, background: '#9D80FF', icon: 'yanlian.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '联络指导', badgeNum: 0, isDetails: false, isLoading: false, background: '#5483EA', icon: 'zhidao.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '消防宣传', badgeNum: 0, isDetails: false, isLoading: false, background: '#FF5D2A', icon: 'xuanchuan.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '投诉举报', badgeNum: 0, isDetails: false, isLoading: false, background: '#5087FF', icon: 'tousu.png', passed: 0, inspected: 0, percentage: 0, data: [] }, |
||||
{ name: '火灾调查', badgeNum: 0, isDetails: false, isLoading: false, background: '#FF404D', icon: 'huozai.png', passed: 0, inspected: 0, percentage: 0, data: [] } |
||||
]; |
||||
this.stationData.forEach(function (element) { |
||||
element.isExpand = true; |
||||
element.isLoading = false; |
||||
element.data = []; |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.isShow = function (element) { |
||||
var isShow = true; |
||||
if (element.creationType == '申领任务') { |
||||
if (this.isSupervisor) { //检查员
|
||||
if ((element.taskType == '熟悉演练') || |
||||
(element.taskType == '联络指导' && element.approvalStatus == '待处理' && element.relatedTaskId == null)) { |
||||
isShow = false; |
||||
} |
||||
} |
||||
else { //消防站
|
||||
if ((element.taskType == '联络指导') || |
||||
(element.taskType == '熟悉演练' && element.approvalStatus == '待处理' && element.relatedTaskId == null) || |
||||
(element.taskType == '双随机' && element.relatedTaskId == null)) { |
||||
isShow = false; |
||||
} |
||||
} |
||||
} |
||||
return isShow; |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.getTaskList = function () { |
||||
return __awaiter(this, void 0, void 0, function () { |
||||
var selectedTime, params; |
||||
var _this = this; |
||||
return __generator(this, function (_a) { |
||||
switch (_a.label) { |
||||
case 0: |
||||
this.cardData.forEach(function (element) { |
||||
element.data = []; |
||||
element.percentage = 0; |
||||
element.passed = 0; |
||||
element.inspected = 0; |
||||
}); |
||||
this.isLoading = true; |
||||
selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'; |
||||
params = { |
||||
Month: selectedTime, |
||||
SupervisorId: this.isSupervisor ? this.userId : null, |
||||
assistantOrganizationId: this.isSupervisor ? null : this.OrganizationId, |
||||
PageNumber: this.PageNumber, |
||||
PageSize: this.PageSize, |
||||
approvalStatuses: ['待处理', '通过', '驳回', '待检查', '已检查'] |
||||
}; |
||||
return [4 /*yield*/, new Promise(function (resolve, reject) { |
||||
_this.http.get('/api/PlanTasks', { |
||||
params: params |
||||
}).subscribe(function (data) { |
||||
_this.isLoading = false; |
||||
// console.log('任务申请列表', data.items)
|
||||
data.items.forEach(function (element) { |
||||
if (_this.isShow(element)) { |
||||
_this.cardData.forEach(function (item, key) { |
||||
element.taskType == item.name ? _this.cardData[key].data.push(element) : null; |
||||
}); |
||||
} |
||||
}); |
||||
_this.cardData.forEach(function (element) { |
||||
element.data.forEach(function (item) { |
||||
item.approvalStatus == '通过' ? element.passed += 1 : null; |
||||
item.approvalStatus == '已检查' ? element.inspected += 1 : null; |
||||
}); |
||||
}); |
||||
_this.cardData.forEach(function (element) { |
||||
element.percentage = Math.round((element.inspected / element.data.length) * 100); |
||||
}); |
||||
resolve(data); |
||||
console.log('并入卡片数据', _this.cardData); |
||||
}); |
||||
})]; |
||||
case 1: return [2 /*return*/, _a.sent()]; |
||||
} |
||||
}); |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.getTaskListPass = function (item) { |
||||
return __awaiter(this, void 0, void 0, function () { |
||||
var selectedTime, params; |
||||
var _this = this; |
||||
return __generator(this, function (_a) { |
||||
switch (_a.label) { |
||||
case 0: |
||||
selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'; |
||||
params = { |
||||
Month: selectedTime, |
||||
approvalStatuses: ['通过', '待检查', '已检查'], |
||||
SupervisorId: this.isSupervisor ? this.userId : null, |
||||
assistantOrganizationId: this.isSupervisor ? null : this.OrganizationId, |
||||
PageNumber: this.PageNumber, |
||||
PageSize: this.PageSize, |
||||
TaskTypes: this.isSupervisor ? ['双随机', '联络指导'] : ['熟悉演练'] |
||||
}; |
||||
item.isLoading = true; |
||||
return [4 /*yield*/, new Promise(function (resolve, reject) { |
||||
_this.http.get('/api/PlanTasks', { |
||||
params: params |
||||
}).subscribe(function (data) { |
||||
item.isLoading = false; |
||||
var listData = [ |
||||
{ name: '双随机', background: '#1D9DFF', icon: 'suiji.png', scale: '0/0', data: [], inspected: 0, finished: 0 }, |
||||
{ name: '行政许可', background: '#42B983', icon: 'xuke.png', scale: '0/0', data: [], inspected: 0, finished: 0 }, |
||||
{ name: '熟悉演练', background: '#9D80FF', icon: 'yanlian.png', scale: '0/0', data: [], inspected: 0, finished: 0 }, |
||||
{ name: '联络指导', background: '#5483EA', icon: 'zhidao.png', scale: '0/0', data: [], inspected: 0, finished: 0 }, |
||||
{ name: '消防宣传', background: '#FF5D2A', icon: 'xuanchuan.png', scale: '0/0', data: [], inspected: 0, finished: 0 }, |
||||
{ name: '投诉举报', background: '#5087FF', icon: 'tousu.png', scale: '0/0', data: [], inspected: 0, finished: 0 }, |
||||
{ name: '火灾调查', background: '#FF404D', icon: 'huozai.png', scale: '0/0', data: [], inspected: 0, finished: 0 } |
||||
]; |
||||
data.items.forEach(function (element) { |
||||
if (_this.isShow(element)) { |
||||
listData.forEach(function (item, key) { |
||||
element.taskType == item.name ? listData[key].data.push(element) : null; |
||||
}); |
||||
} |
||||
}); |
||||
for (var index = 0; index < listData.length; index++) { |
||||
var element = listData[index]; |
||||
if (element.data.length == 0) { |
||||
listData.splice(index, 1); |
||||
index--; |
||||
} |
||||
} |
||||
item.data = listData; |
||||
console.log('当前登录用户所有通过的任务', item); |
||||
item.allUnitsNum = 0; |
||||
item.awaitInspect = 0; |
||||
item.inspected = 0; |
||||
item.finished = 0; |
||||
item.data.forEach(function (element) { |
||||
item.allUnitsNum += element.data.length; |
||||
element.data.forEach(function (i) { |
||||
i.approvalStatus == '待检查' ? item.awaitInspect += 1 : null; |
||||
i.approvalStatus == '已检查' ? item.inspected += 1 : null; |
||||
i.approvalStatus == '待检查' ? element.inspected += 1 : null; |
||||
i.approvalStatus == '已检查' ? element.finished += 1 : null; |
||||
}); |
||||
}); |
||||
item.percentage = Math.round((item.inspected / item.allUnitsNum) * 100); |
||||
resolve(data); |
||||
}); |
||||
})]; |
||||
case 1: return [2 /*return*/, _a.sent()]; |
||||
} |
||||
}); |
||||
}); |
||||
}; |
||||
//接受任务
|
||||
StationWeeklyPlanComponent.prototype.accept = function (i, item) { |
||||
var _this = this; |
||||
if (i.approvalStatus == '通过') { |
||||
this.message.create('warning', '不能重复接受'); |
||||
return; |
||||
} |
||||
if (i.approvalStatus == '待检查') { |
||||
this.message.create('warning', '任务处于待检查状态,不能再次接受'); |
||||
return; |
||||
} |
||||
this.modal.confirm({ |
||||
nzTitle: "\u786E\u5B9A\u8981\u63A5\u53D7\u8BE5\u4EFB\u52A1\u5417?", |
||||
nzOkText: '确定', |
||||
nzOkType: 'default', |
||||
nzOnOk: function () { |
||||
item.isLoading = true; |
||||
_this.http.post("/api/PlanTasks/Approval/" + i.id, null, { |
||||
params: { |
||||
approvalStatus: '通过' |
||||
} |
||||
}).subscribe({ |
||||
next: function (data) { |
||||
_this.message.create('success', '已接受'); |
||||
i.approvalStatus = '通过'; |
||||
item.isLoading = false; |
||||
item.passed += 1; |
||||
_this.getTaskListPass(_this.stationData[0]); |
||||
}, |
||||
error: function (err) { |
||||
_this.message.create('warning', '接受失败'); |
||||
item.isLoading = false; |
||||
} |
||||
}); |
||||
}, |
||||
nzCancelText: '取消' |
||||
}); |
||||
}; |
||||
//拒绝任务
|
||||
StationWeeklyPlanComponent.prototype.reject = function (i, item) { |
||||
var _this = this; |
||||
if (i.approvalStatus == '驳回') { |
||||
this.message.create('warning', '不能重复驳回'); |
||||
return; |
||||
} |
||||
this.modal.confirm({ |
||||
nzTitle: "\u786E\u5B9A\u8981\u62D2\u7EDD\u8BE5\u4EFB\u52A1\u5417?", |
||||
nzOkText: '确定', |
||||
nzOkType: 'default', |
||||
nzOnOk: function () { |
||||
item.isLoading = true; |
||||
_this.http.post("/api/PlanTasks/Approval/" + i.id, null, { |
||||
params: { |
||||
approvalStatus: '驳回' |
||||
} |
||||
}).subscribe({ |
||||
next: function (data) { |
||||
_this.message.create('success', '已拒绝'); |
||||
i.approvalStatus = '驳回'; |
||||
item.isLoading = false; |
||||
item.passed -= 1; |
||||
_this.getTaskListPass(_this.stationData[0]); |
||||
}, |
||||
error: function (err) { |
||||
_this.message.create('warning', '拒绝失败'); |
||||
item.isLoading = false; |
||||
} |
||||
}); |
||||
}, |
||||
nzCancelText: '取消' |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.ngOnInit = function () { |
||||
var _this = this; |
||||
this.OrganizationId = JSON.parse(sessionStorage.getItem('userData')).organizationId; |
||||
this.userId = JSON.parse(sessionStorage.getItem('userData')).id; |
||||
this.userName = JSON.parse(sessionStorage.getItem('userData')).name; |
||||
this.organizationName = JSON.parse(sessionStorage.getItem('userData')).organizationName; |
||||
var roles = JSON.parse(sessionStorage.getItem('userData')).roles; |
||||
var isSupervisor = roles.find(function (item) { |
||||
return item.name.indexOf('检查') != -1; |
||||
}); |
||||
isSupervisor ? this.isSupervisor = true : this.isSupervisor = false; |
||||
if (isSupervisor) { |
||||
this.stationData[0].name = this.userName; |
||||
} |
||||
else { |
||||
this.stationData[0].name = this.organizationName; |
||||
} |
||||
this.selectedMonth = new Date().getMonth() + 1; |
||||
// this.getAllStation()
|
||||
this.getTaskList(); |
||||
this.getTaskListPass(this.stationData[0]); |
||||
this.getTuesdayThursdayNum(); |
||||
setTimeout(function () { |
||||
_this.rollStart(); |
||||
}, 0); |
||||
this.newTaskMessage.getMessage().subscribe(function (data) { |
||||
console.log('具体任务信息', data); |
||||
if (data.signalRData.content == '您有一条新的一体化任务,请注意查收。') { |
||||
_this.cardData.forEach(function (item) { |
||||
if (item.name == data.taskType) { |
||||
console.log('要push的数组', item.data); |
||||
item.data.unshift(data); |
||||
if (!item.isDetails) { |
||||
item.badgeNum += 1; |
||||
} |
||||
if (data.approvalStatus == '通过') { |
||||
item.passed += 1; |
||||
_this.getTaskListPass(_this.stationData[0]); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
if (data.signalRData.content == '您参与的任务已取消,请点击查看详情。') { |
||||
// this.cardData.forEach((item: any) => {
|
||||
// if (item.name == data.taskType) {
|
||||
// for (let index = 0; index < item.data.length; index++) {
|
||||
// const element = item.data[index];
|
||||
// if (element.id == data.signalRData.planTaskId) {
|
||||
// item.data.splice(index, 1)
|
||||
// index--
|
||||
// }
|
||||
// }
|
||||
// if (!item.isDetails) {
|
||||
// item.badgeNum -= 1
|
||||
// }
|
||||
// this.getTaskListPass(this.stationData[0])
|
||||
// }
|
||||
// })
|
||||
} |
||||
if (data.signalRData.content == '您参与的任务时间变更,请点击查看详情。') { |
||||
_this.stationData[0].data.forEach(function (element) { |
||||
if (element.name == data.taskType) { |
||||
element.data.forEach(function (item) { |
||||
if (item.id == data.id) { |
||||
item.planTime = data.planTime; |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.rollStart = function () { |
||||
var ROLL_SPEED = 100; |
||||
var noticeList1 = document.getElementById('notice-list'); |
||||
var noticeList2 = document.getElementById('notice-list-2'); |
||||
var listWrapper = document.getElementById('list-wrapper'); |
||||
noticeList2.innerHTML = noticeList1.innerHTML; |
||||
this.timer = setInterval(rollStart, ROLL_SPEED); |
||||
function rollStart() { |
||||
if (Math.abs(_subStr(listWrapper.style.top)) >= noticeList1.clientHeight) { |
||||
listWrapper.style.top = '0px'; |
||||
} |
||||
else { |
||||
var top = listWrapper.style.top; |
||||
listWrapper.style.top = _subStr(top) - 1 + 'px'; |
||||
} |
||||
} |
||||
// 截取px前数值
|
||||
function _subStr(str) { |
||||
var index = str.indexOf('px'); |
||||
if (index > -1) { |
||||
return parseFloat(str.substr(0, index + 1)); |
||||
} |
||||
} |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.mouseEnter = function () { |
||||
window.clearInterval(this.timer); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.mouseleave = function () { |
||||
this.rollStart(); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.ngOnDestroy = function () { |
||||
console.log('退出了'); |
||||
this.mouseEnter(); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.expandcarditem = function (item) { |
||||
item.isExpand = !item.isExpand; |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.taskDetails = function (item) { |
||||
var _this = this; |
||||
// console.log(item)
|
||||
var modal = this.modal.create({ |
||||
nzTitle: item.name, |
||||
nzContent: task_details_component_1.TaskDetailsComponent, |
||||
nzViewContainerRef: this.viewContainerRef, |
||||
nzWidth: 900, |
||||
nzMaskClosable: false, |
||||
nzFooter: null, |
||||
nzComponentParams: { |
||||
data: item, |
||||
parent: this |
||||
} |
||||
}); |
||||
var instance = modal.getContentComponent(); |
||||
modal.afterOpen.subscribe(function () { return console.log('[afterOpen] emitted!'); }); |
||||
modal.afterClose.subscribe(function (result) { |
||||
// item
|
||||
// this.getTaskList()
|
||||
_this.getTaskListPass(_this.stationData[0]); |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.apply = function (item) { |
||||
var _this = this; |
||||
var modal = this.modal.create({ |
||||
nzTitle: '新增' + item.name + '任务', |
||||
nzContent: create_task_component_1.CreateTaskComponent, |
||||
nzViewContainerRef: this.viewContainerRef, |
||||
nzWidth: 660, |
||||
nzMaskClosable: false, |
||||
nzComponentParams: { |
||||
title: item.name |
||||
}, |
||||
nzOnOk: function () { return __awaiter(_this, void 0, void 0, function () { |
||||
var _this = this; |
||||
return __generator(this, function (_a) { |
||||
switch (_a.label) { |
||||
case 0: |
||||
console.log(instance.validateForm.value); |
||||
if (!instance.validateForm.valid) return [3 /*break*/, 2]; |
||||
return [4 /*yield*/, new Promise(function (resolve, reject) { |
||||
var selectedMonth = _this.selectedMonth < 10 ? "0" + _this.selectedMonth : _this.selectedMonth; |
||||
var selectedTime = _this.selectedYear + '-' + selectedMonth + '-' + '01'; |
||||
var body = { |
||||
month: selectedTime, |
||||
taskName: instance.validateForm.value.taskname, |
||||
taskType: instance.validateForm.value.taskname, |
||||
companyId: instance.validateForm.value.unitname.id, |
||||
organizationId: _this.OrganizationId, |
||||
supervisorIds: _this.isSupervisor ? [_this.userId] : [], |
||||
assistantOrganizationIds: _this.isSupervisor ? [] : [_this.OrganizationId], |
||||
creationType: '自主任务', |
||||
approvalStatus: '通过' |
||||
}; |
||||
_this.http.post('/api/PlanTasks', body).subscribe({ |
||||
next: function (data) { |
||||
console.log(item); |
||||
data.company = instance.validateForm.value.unitname; |
||||
item.data.push(data); |
||||
item.passed += 1; |
||||
// this.getTaskList()
|
||||
_this.getTaskListPass(_this.stationData[0]); |
||||
_this.message.create('success', '创建成功'); |
||||
resolve(data); |
||||
return true; |
||||
}, |
||||
error: function (err) { |
||||
_this.message.create('warning', '创建失败'); |
||||
reject(err); |
||||
return false; |
||||
} |
||||
}); |
||||
})]; |
||||
case 1: |
||||
_a.sent(); |
||||
return [3 /*break*/, 3]; |
||||
case 2: |
||||
this.message.create('warning', '请填写完整!'); |
||||
return [2 /*return*/, false]; |
||||
case 3: return [2 /*return*/]; |
||||
} |
||||
}); |
||||
}); } |
||||
}); |
||||
var instance = modal.getContentComponent(); |
||||
modal.afterOpen.subscribe(function () { return console.log('[afterOpen] emitted!'); }); |
||||
modal.afterClose.subscribe(function (result) { return console.log('[afterClose] The result is:', result); }); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.createTask = function (element) { |
||||
var _this = this; |
||||
console.log(element); |
||||
var taskIds = []; |
||||
element.data.forEach(function (item) { |
||||
item.data.forEach(function (i) { |
||||
i.planTime && i.approvalStatus != '已检查' ? taskIds.push(i.id) : null; |
||||
}); |
||||
}); |
||||
var params = { |
||||
ids: taskIds, |
||||
approvalStatus: '待检查' |
||||
}; |
||||
this.http.post('/api/PlanTasks/ApprovalMany', null, { params: params }).subscribe({ |
||||
next: function (data) { |
||||
_this.getTaskListPass(_this.stationData[0]); |
||||
_this.message.create('success', '发布成功'); |
||||
}, |
||||
error: function (err) { |
||||
_this.message.create('warning', '发布失败'); |
||||
} |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.adjustment = function (item) { |
||||
var _this = this; |
||||
var selectedTime = this.selectedYear + '-' + this.selectedMonth + '-' + '01'; |
||||
var modal = this.modal.create({ |
||||
nzTitle: "任务调整", |
||||
nzContent: plan_adjustment_component_1.PlanAdjustmentComponent, |
||||
nzViewContainerRef: this.viewContainerRef, |
||||
nzWidth: 900, |
||||
nzFooter: null, |
||||
nzComponentParams: { |
||||
data: JSON.parse(JSON.stringify(item)), |
||||
time: selectedTime, |
||||
level: '非大队' |
||||
} |
||||
}); |
||||
var instance = modal.getContentComponent(); |
||||
modal.afterClose.subscribe(function (result) { |
||||
_this.getTaskList(); |
||||
_this.getTaskListPass(_this.stationData[0]); |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.allPass = function (item) { |
||||
var _this = this; |
||||
console.log(item); |
||||
this.modal.confirm({ |
||||
nzTitle: "\u786E\u5B9A\u8981\u5168\u90E8\u63A5\u53D7\u8BE5\u6A21\u5757\u4E0B\u6240\u6709\u4EFB\u52A1\u5417?", |
||||
nzOkText: '确定', |
||||
nzOkType: 'default', |
||||
nzOnOk: function () { |
||||
var ids = []; |
||||
item.data.forEach(function (element) { |
||||
if (element.approvalStatus == '待处理' || element.approvalStatus == '驳回') |
||||
ids.push(element.id); |
||||
}); |
||||
_this.http.post("/api/PlanTasks/ApprovalMany", null, { |
||||
params: { |
||||
ids: ids, |
||||
approvalStatus: '通过' |
||||
} |
||||
}).subscribe({ |
||||
next: function (data) { |
||||
_this.message.create('success', '成功'); |
||||
item.data.forEach(function (element) { |
||||
element.approvalStatus = '通过'; |
||||
}); |
||||
_this.getTaskListPass(_this.stationData[0]); |
||||
}, |
||||
error: function (err) { |
||||
_this.message.create('warning', '失败'); |
||||
item.isLoading = false; |
||||
} |
||||
}); |
||||
}, |
||||
nzCancelText: '取消' |
||||
}); |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.openchat = function (item) { |
||||
console.log(item); |
||||
this.taskId = item.id; |
||||
this.ischat = true; |
||||
}; |
||||
StationWeeklyPlanComponent.prototype.closechat = function () { |
||||
this.ischat = false; |
||||
}; |
||||
StationWeeklyPlanComponent = __decorate([ |
||||
core_1.Component({ |
||||
selector: 'app-station-weekly-plan', |
||||
templateUrl: './station-weekly-plan.component.html', |
||||
styleUrls: ['./station-weekly-plan.component.scss'] |
||||
}) |
||||
], StationWeeklyPlanComponent); |
||||
return StationWeeklyPlanComponent; |
||||
}()); |
||||
exports.StationWeeklyPlanComponent = StationWeeklyPlanComponent; |
@ -1,87 +1,123 @@
|
||||
if (typeof jQuery !== "undefined" && typeof saveAs !== "undefined") { |
||||
(function ($) { |
||||
$.fn.wordExport = function (fileName) { |
||||
fileName = typeof fileName !== 'undefined' ? fileName : "jQuery-Word-Export"; |
||||
var statics = { |
||||
mhtml: { |
||||
top: "Mime-Version: 1.0\nContent-Base: " + location.href + "\nContent-Type: Multipart/related; boundary=\"NEXT.ITEM-BOUNDARY\";type=\"text/html\"\n\n--NEXT.ITEM-BOUNDARY\nContent-Type: text/html; charset=\"utf-8\"\nContent-Location: " + location.href + "\n\n<!DOCTYPE html>\n<html>\n_html_</html>", |
||||
head: "<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n<style>\n_styles_\n</style>\n</head>\n", |
||||
body: "<body>_body_</body>" |
||||
} |
||||
(function ($) { |
||||
$.fn.wordExport = async function (fileName) { |
||||
fileName = typeof fileName !== 'undefined' ? fileName : "jQuery-Word-Export"; |
||||
var statics = { |
||||
mhtml: { |
||||
top: "Mime-Version: 1.0\nContent-Base: " + location.href + "\nContent-Type: Multipart/related; boundary=\"NEXT.ITEM-BOUNDARY\";type=\"text/html\"\n\n--NEXT.ITEM-BOUNDARY\nContent-Type: text/html; charset=\"utf-8\"\nContent-Location: " + location.href + "\n\n<!DOCTYPE html>\n<html>\n_html_</html>", |
||||
head: "<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n<style>\n_styles_\n</style>\n</head>\n", |
||||
body: "<body>_body_</body>" |
||||
} |
||||
}; |
||||
var options = { |
||||
maxWidth: 624 |
||||
}; |
||||
// Clone selected element before manipulating it
|
||||
var markup = $(this).clone(); |
||||
|
||||
// Remove hidden elements from the output
|
||||
markup.each(function () { |
||||
var self = $(this); |
||||
if (self.is(':hidden')) |
||||
self.remove(); |
||||
}); |
||||
|
||||
// Embed all images using Data URLs
|
||||
var images = Array(); |
||||
var img = markup.find('img'); |
||||
for (var i = 0; i < img.length; i++) { |
||||
await getBase64(img[i].src, (data) => { |
||||
// 将url图片转为了base64的data
|
||||
// img[i].setAttribute("src", data);
|
||||
img[i].setAttribute("src", data); |
||||
}) |
||||
// Calculate dimensions of output image
|
||||
var w = Math.min(img[i].width, options.maxWidth); |
||||
var h = img[i].height * (w / img[i].width); |
||||
// Create canvas for converting image to data URL
|
||||
var canvas = document.createElement("canvas"); |
||||
// canvas.style.display="none";//防止页面由于导出产生变化
|
||||
canvas.width = w; |
||||
canvas.height = h; |
||||
|
||||
var img_id = '#' + img[i].id |
||||
// // img[i].src = img[i].src.replace("https","http"); //处理导出不显示的问题,如果在某些代码中出现了图片无法显示问题,可以加入该代码
|
||||
$(canvas).attr("id", "test_word_img_" + i).width(w).height(h).insertAfter(img_id); //注释掉img处理的其他代码
|
||||
|
||||
|
||||
// Draw image to canvas
|
||||
// var context = canvas.getContext('2d');
|
||||
// context.drawImage(img[i], 0, 0, w, h);
|
||||
// // Get data URL encoding of image
|
||||
// var uri = canvas.toDataURL("image/png/jpg");
|
||||
// $(img[i]).attr("src", img[i].src);
|
||||
// img[i].width = w;
|
||||
// img[i].height = h;
|
||||
// console.log(img[i])
|
||||
// // Save encoded image to array
|
||||
// images[i] = {
|
||||
// type: uri.substring(uri.indexOf(":") + 1, uri.indexOf(";")),
|
||||
// encoding: uri.substring(uri.indexOf(";") + 1, uri.indexOf(",")),
|
||||
// location: $(img[i]).attr("src"),
|
||||
// data: uri.substring(uri.indexOf(",") + 1)
|
||||
// };
|
||||
|
||||
function getBase64(url, callback) { |
||||
return new Promise((resolve, reject) => { |
||||
var Img = new Image(), |
||||
dataURL = ''; |
||||
Img.src = url + "?v=" + Math.random(); |
||||
Img.setAttribute("crossOrigin", 'Anonymous') |
||||
Img.onload = function () { |
||||
var canvas = document.createElement("canvas"), |
||||
width = Img.width, |
||||
height = Img.height; |
||||
canvas.width = width; |
||||
canvas.height = height; |
||||
canvas.getContext("2d").drawImage(Img, 0, 0, width, height); |
||||
dataURL = canvas.toDataURL('image/jpeg'); |
||||
callback ? callback(dataURL) : null; |
||||
resolve() |
||||
}; |
||||
var options = { |
||||
maxWidth: 624 |
||||
}; |
||||
// Clone selected element before manipulating it
|
||||
var markup = $(this).clone(); |
||||
|
||||
// Remove hidden elements from the output
|
||||
markup.each(function () { |
||||
var self = $(this); |
||||
if (self.is(':hidden')) |
||||
self.remove(); |
||||
}); |
||||
|
||||
// Embed all images using Data URLs
|
||||
var images = Array(); |
||||
var img = markup.find('img'); |
||||
for (var i = 0; i < img.length; i++) { |
||||
// Calculate dimensions of output image
|
||||
var w = Math.min(img[i].width, options.maxWidth); |
||||
var h = img[i].height * (w / img[i].width); |
||||
// Create canvas for converting image to data URL
|
||||
var canvas = document.createElement("CANVAS"); |
||||
canvas.width = w; |
||||
canvas.height = h; |
||||
// Draw image to canvas
|
||||
var context = canvas.getContext('2d'); |
||||
context.drawImage(img[i], 0, 0, w, h); |
||||
// Get data URL encoding of image
|
||||
var uri = canvas.toDataURL("image/png/jpg"); |
||||
$(img[i]).attr("src", img[i].src); |
||||
img[i].width = w; |
||||
img[i].height = h; |
||||
// Save encoded image to array
|
||||
images[i] = { |
||||
type: uri.substring(uri.indexOf(":") + 1, uri.indexOf(";")), |
||||
encoding: uri.substring(uri.indexOf(";") + 1, uri.indexOf(",")), |
||||
location: $(img[i]).attr("src"), |
||||
data: uri.substring(uri.indexOf(",") + 1) |
||||
}; |
||||
} |
||||
|
||||
// Prepare bottom of mhtml file with image data
|
||||
var mhtmlBottom = "\n"; |
||||
for (var i = 0; i < images.length; i++) { |
||||
mhtmlBottom += "--NEXT.ITEM-BOUNDARY\n"; |
||||
mhtmlBottom += "Content-Location: " + images[i].location + "\n"; |
||||
mhtmlBottom += "Content-Type: " + images[i].type + "\n"; |
||||
mhtmlBottom += "Content-Transfer-Encoding: " + images[i].encoding + "\n\n"; |
||||
mhtmlBottom += images[i].data + "\n\n"; |
||||
} |
||||
mhtmlBottom += "--NEXT.ITEM-BOUNDARY--"; |
||||
|
||||
//TODO: load css from included stylesheet
|
||||
|
||||
//var styles=' /* Font Definitions */@font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-alt:SimSun;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 680460288 22 0 262145 0;} @font-face{font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;mso-font-charset:1;mso-generic-font-family:roman;mso-font-format:other;mso-font-pitch:variable;mso-font-signature:0 0 0 0 0 0;} @font-face{font-family:"\@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 680460288 22 0 262145 0;}/* Style Definitions */p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-unhide:no;mso-style-qformat:yes;mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;mso-pagination:widow-orphan;font-size:14.0pt;font-family:宋体;mso-bidi-font-family:宋体;}p.MsoHeader, li.MsoHeader, div.MsoHeader{mso-style-noshow:yes;mso-style-priority:99;mso-style-link:"页眉 Char";margin:0cm;margin-bottom:.0001pt;text-align:center;mso-pagination:widow-orphan;layout-grid-mode:char;font-size:9.0pt;font-family:宋体;mso-bidi-font-family:宋体;}p.MsoFooter, li.MsoFooter, div.MsoFooter{mso-style-noshow:yes;mso-style-priority:99;mso-style-link:"页脚 Char";margin:0cm;margin-bottom:.0001pt;mso-pagination:widow-orphan;layout-grid-mode:char;font-size:9.0pt;font-family:宋体;mso-bidi-font-family:宋体;}p.MsoAcetate, li.MsoAcetate, div.MsoAcetate{mso-style-noshow:yes;mso-style-priority:99;mso-style-link:"批注框文本 Char";margin:0cm;margin-bottom:.0001pt;mso-pagination:widow-orphan;font-size:9.0pt;font-family:宋体;mso-bidi-font-family:宋体;}span.Char{mso-style-name:"页眉 Char";mso-style-noshow:yes;mso-style-priority:99;mso-style-unhide:no;mso-style-locked:yes;mso-style-link:页眉;font-family:宋体;mso-ascii-font-family:宋体;mso-fareast-font-family:宋体;mso-hansi-font-family:宋体;}span.Char0{mso-style-name:"页脚 Char";mso-style-noshow:yes;mso-style-priority:99;mso-style-unhide:no;mso-style-locked:yes;mso-style-link:页脚;font-family:宋体;mso-ascii-font-family:宋体;mso-fareast-font-family:宋体;mso-hansi-font-family:宋体;}span.Char1{mso-style-name:"批注框文本 Char";mso-style-noshow:yes;mso-style-priority:99;mso-style-unhide:no;mso-style-locked:yes;mso-style-link:批注框文本;font-family:宋体;mso-ascii-font-family:宋体;mso-fareast-font-family:宋体;mso-hansi-font-family:宋体;}p.msochpdefault, li.msochpdefault, div.msochpdefault{mso-style-name:msochpdefault;mso-style-unhide:no;mso-margin-top-alt:auto;margin-right:0cm;mso-margin-bottom-alt:auto;margin-left:0cm;mso-pagination:widow-orphan;font-size:10.0pt;font-family:宋体;mso-bidi-font-family:宋体;}span.msonormal0{mso-style-name:msonormal;mso-style-unhide:no;}.MsoChpDefault{mso-style-type:export-only;mso-default-props:yes;font-size:10.0pt;mso-ansi-font-size:10.0pt;mso-bidi-font-size:10.0pt;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-font-kerning:0pt;}/* Page Definitions */ @page WordSection1{size:595.3pt 841.9pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;mso-header-margin:42.55pt;mso-footer-margin:49.6pt;mso-paper-source:0;}div.WordSection1{page:WordSection1;}';
|
||||
|
||||
var styles = '' |
||||
|
||||
// Aggregate parts of the file together
|
||||
var fileContent = statics.mhtml.top.replace("_html_", statics.mhtml.head.replace("_styles_", styles) + statics.mhtml.body.replace("_body_", markup.html())) + mhtmlBottom; |
||||
|
||||
// Create a Blob with the file contents
|
||||
var blob = new Blob([fileContent], { |
||||
type: "application/msword;charset=utf-8" |
||||
}); |
||||
saveAs(blob, fileName + ".doc"); |
||||
}; |
||||
})(jQuery); |
||||
}) |
||||
|
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
// Prepare bottom of mhtml file with image data
|
||||
var mhtmlBottom = "\n"; |
||||
for (var i = 0; i < images.length; i++) { |
||||
mhtmlBottom += "--NEXT.ITEM-BOUNDARY\n"; |
||||
mhtmlBottom += "Content-Location: " + images[i].location + "\n"; |
||||
mhtmlBottom += "Content-Type: " + images[i].type + "\n"; |
||||
mhtmlBottom += "Content-Transfer-Encoding: " + images[i].encoding + "\n\n"; |
||||
mhtmlBottom += images[i].data + "\n\n"; |
||||
} |
||||
mhtmlBottom += "--NEXT.ITEM-BOUNDARY--"; |
||||
|
||||
//TODO: load css from included stylesheet
|
||||
|
||||
//var styles=' /* Font Definitions */@font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-alt:SimSun;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 680460288 22 0 262145 0;} @font-face{font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;mso-font-charset:1;mso-generic-font-family:roman;mso-font-format:other;mso-font-pitch:variable;mso-font-signature:0 0 0 0 0 0;} @font-face{font-family:"\@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 680460288 22 0 262145 0;}/* Style Definitions */p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-unhide:no;mso-style-qformat:yes;mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;mso-pagination:widow-orphan;font-size:14.0pt;font-family:宋体;mso-bidi-font-family:宋体;}p.MsoHeader, li.MsoHeader, div.MsoHeader{mso-style-noshow:yes;mso-style-priority:99;mso-style-link:"页眉 Char";margin:0cm;margin-bottom:.0001pt;text-align:center;mso-pagination:widow-orphan;layout-grid-mode:char;font-size:9.0pt;font-family:宋体;mso-bidi-font-family:宋体;}p.MsoFooter, li.MsoFooter, div.MsoFooter{mso-style-noshow:yes;mso-style-priority:99;mso-style-link:"页脚 Char";margin:0cm;margin-bottom:.0001pt;mso-pagination:widow-orphan;layout-grid-mode:char;font-size:9.0pt;font-family:宋体;mso-bidi-font-family:宋体;}p.MsoAcetate, li.MsoAcetate, div.MsoAcetate{mso-style-noshow:yes;mso-style-priority:99;mso-style-link:"批注框文本 Char";margin:0cm;margin-bottom:.0001pt;mso-pagination:widow-orphan;font-size:9.0pt;font-family:宋体;mso-bidi-font-family:宋体;}span.Char{mso-style-name:"页眉 Char";mso-style-noshow:yes;mso-style-priority:99;mso-style-unhide:no;mso-style-locked:yes;mso-style-link:页眉;font-family:宋体;mso-ascii-font-family:宋体;mso-fareast-font-family:宋体;mso-hansi-font-family:宋体;}span.Char0{mso-style-name:"页脚 Char";mso-style-noshow:yes;mso-style-priority:99;mso-style-unhide:no;mso-style-locked:yes;mso-style-link:页脚;font-family:宋体;mso-ascii-font-family:宋体;mso-fareast-font-family:宋体;mso-hansi-font-family:宋体;}span.Char1{mso-style-name:"批注框文本 Char";mso-style-noshow:yes;mso-style-priority:99;mso-style-unhide:no;mso-style-locked:yes;mso-style-link:批注框文本;font-family:宋体;mso-ascii-font-family:宋体;mso-fareast-font-family:宋体;mso-hansi-font-family:宋体;}p.msochpdefault, li.msochpdefault, div.msochpdefault{mso-style-name:msochpdefault;mso-style-unhide:no;mso-margin-top-alt:auto;margin-right:0cm;mso-margin-bottom-alt:auto;margin-left:0cm;mso-pagination:widow-orphan;font-size:10.0pt;font-family:宋体;mso-bidi-font-family:宋体;}span.msonormal0{mso-style-name:msonormal;mso-style-unhide:no;}.MsoChpDefault{mso-style-type:export-only;mso-default-props:yes;font-size:10.0pt;mso-ansi-font-size:10.0pt;mso-bidi-font-size:10.0pt;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman";mso-font-kerning:0pt;}/* Page Definitions */ @page WordSection1{size:595.3pt 841.9pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;mso-header-margin:42.55pt;mso-footer-margin:49.6pt;mso-paper-source:0;}div.WordSection1{page:WordSection1;}';
|
||||
|
||||
var styles = '' |
||||
|
||||
// Aggregate parts of the file together
|
||||
var fileContent = statics.mhtml.top.replace("_html_", statics.mhtml.head.replace("_styles_", styles) + statics.mhtml.body.replace("_body_", markup.html())) + mhtmlBottom; |
||||
|
||||
// Create a Blob with the file contents
|
||||
var blob = new Blob([fileContent], { |
||||
type: "application/msword;charset=utf-8" |
||||
}); |
||||
saveAs(blob, fileName + ".doc"); |
||||
}; |
||||
})(jQuery); |
||||
} else { |
||||
if (typeof jQuery === "undefined") { |
||||
console.error("jQuery Word Export: missing dependency (jQuery)"); |
||||
} |
||||
if (typeof saveAs === "undefined") { |
||||
console.error("jQuery Word Export: missing dependency (FileSaver.js)"); |
||||
} |
||||
} |
||||
if (typeof jQuery === "undefined") { |
||||
console.error("jQuery Word Export: missing dependency (jQuery)"); |
||||
} |
||||
if (typeof saveAs === "undefined") { |
||||
console.error("jQuery Word Export: missing dependency (FileSaver.js)"); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue