123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- "use strict";
- app.controller("sysconfigCtrl", ["$parse", "$rootScope", "$scope", "$state", "$timeout", "$interval", "$modal", "$window", "SweetAlert", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_sysinfo", "api_is_category","api_bpm_domain","api_simple", "FileUploader", "fileReader", "api_login", "api_wechatfile","api_user_data", function ($parse, t, a, n, e, i, s, r, o, l, u, d, c, g, api_is_category,api_bpm_domain, api_simple, FileUploader, fileReader, api_login, api_wechatfile,api_user_data) {
- a.langs = l.getAllLangs(), a.lang = "zh-cn", l.setCurrentLang(a.lang);
- var f = (t.user, r._, {
- idx: 0,
- sum: 1e3
- });
- // 当前所属院区或责任科室
- if(t.user.duty){
- a.branchId = t.user.duty.branch;
- }else if(t.user.branch){
- a.branchId = t.user.branch.id;
- }
- a.hospitalConfig = [];
- a.hospitalObj = {};
- // a.autoCloseIncidentHour = 24;//默认24小时自动关单
- a.changeAutoCloseIncidentHour = function(e){
- var v = parseFloat(e.target.value)?parseFloat(e.target.value):0;
- a.autoCloseIncidentHour.valueconfig = v > 0 ? v : 0;
- }
- //清除缓存
- a.refreshCache = function () {
- t.isMask = true;
- api_bpm_domain.refreshCache({}).then(function (result) {
- t.isMask = false;
- if (result.status == 200) {
- o.swal({
- title: "操作成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- })
- } else {
- o.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- })
- }
- }).catch(function(err){
- t.isMask = false;
- })
- }
- //清除缓存-single
- a.refreshCacheSingle = function (type) {
- t.isMask = true;
- api_user_data.cacheFresh(type).then(function (result) {
- t.isMask = false;
- if (result.status == 200) {
- o.swal({
- title: "操作成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- })
- } else {
- o.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- })
- }
- }).catch(function(err){
- t.isMask = false;
- })
- }
- // 切换三方设备
- a.changeCcType = function(type){
- a.hospitalObj.ccType.value = type;
- for (var key in a.hospitalObj) {
- if(key != 'ccType'){
- a.hospitalObj[key].value = '';
- }
- }
- }
- // 图片logo上传----start
- a.imgshows = [];
- a.uploadimgs = [];
- var model = $parse("upload_img");
- var modelSetter = model.assign;
- var uploader = (a.uploader = new FileUploader({
- url: "/uploader",
- }));
- a.getDetail = function(img){
- function getImageFileFromUrl(url, imageName, callback) {
- // imageName一定要带上后缀
- var blob = null
- var xhr = new XMLHttpRequest()
- xhr.open('GET', url)
- xhr.setRequestHeader('Accept', 'image/jpeg')
- xhr.responseType = 'blob'
- xhr.onload = () => {
- if (xhr.status === 200) {
- blob = xhr.response
- let imgFile = new File([blob], imageName, {type: 'image/jpeg'})
- console.log(imgFile)
- callback.call(this, imgFile)
- }
- }
- xhr.send()
- }
- getImageFileFromUrl(img, img.match(/[^\/\\]+$/) ? img.match(/[^\/\\]+$/)[0] : '',function(file){
- var dummy = new FileUploader.FileItem(uploader, file);
- uploader.queue = [dummy];
- getFile(file, a);
- })
- //获得预览图地址并且把file对象放入上传合集内
- function getFile(imgupload, a) {
- if (!imgupload) {
- return;
- }
- fileReader.readAsDataUrl(imgupload, a).then(function (result) {
- // console.log(result)
- a.imgshows = [result];
- var file = imgupload;
- a.uploadimgs = [file]; //这里是放着传给后台的数据file,下面controller的时候会有
- console.log(a.imgshows, a.uploadimgs);
- if (a.imgshows.length < 1) {
- $("#upupgogo").show();
- } else {
- $("#upupgogo").hide();
- }
- });
- }
- }
- // 添加
- a.change = function (event) {
- a.isEdit = true;
- var element = $(".upinp");
- modelSetter(a, element[0].files[0]);
- //附件预览
- a.imgupload = event.files[0];
- getFile(a.imgupload, a);
- //获得预览图地址并且把file对象放入上传合集内
- function getFile(imgupload, a) {
- if (!imgupload) {
- return;
- }
- fileReader.readAsDataUrl(imgupload, a).then(function (result) {
- // console.log(result)
- a.imgshows = [result];
- var file = document.querySelector("#upupgogo input[type=file]").files[0];
- a.uploadimgs = [file]; //这里是放着传给后台的数据file,下面controller的时候会有
- console.log(a.imgshows, a.uploadimgs);
- if (a.imgshows.length < 1) {
- $("#upupgogo").show();
- } else {
- $("#upupgogo").hide();
- }
- });
- }
- };
- // 删除
- a.uploadimg_del = function (index, imgs) {
- console.log(index, imgs);
- a.isEdit = true;
- a.imgshows.splice(index, 1);
- a.uploadimgs.splice(index, 1);
- a.uploader.queue.shift();
- if (a.imgshows.length < 1) {
- $("#upupgogo").show();
- } else {
- $("#upupgogo").hide();
- }
- document.querySelector("#upupgogo input[type=file]").value = null;
- };
- // 图片logo上传----end
- // 图片favicon上传----start
- a.isEdit1 = false;
- a.imgshows1 = [];
- a.uploadimgs1 = [];
- var model1 = $parse("upload_img1");
- var model1Setter = model1.assign;
- var uploader1 = (a.uploader1 = new FileUploader({
- url: "/uploader1",
- }));
- a.getDetail1 = function(img){
- function getImageFileFromUrl(url, imageName, callback) {
- // imageName一定要带上后缀
- var blob = null
- var xhr = new XMLHttpRequest()
- xhr.open('GET', url)
- xhr.setRequestHeader('Accept', 'image/jpeg')
- xhr.responseType = 'blob'
- xhr.onload = () => {
- if (xhr.status === 200) {
- blob = xhr.response
- let imgFile = new File([blob], imageName, {type: 'image/jpeg'})
- console.log(imgFile)
- callback.call(this, imgFile)
- }
- }
- xhr.send()
- }
- getImageFileFromUrl(img, img.match(/[^\/\\]+$/) ? img.match(/[^\/\\]+$/)[0] : '',function(file){
- var dummy = new FileUploader.FileItem(uploader1, file);
- uploader1.queue = [dummy];
- getFile(file, a);
- })
- //获得预览图地址并且把file对象放入上传合集内
- function getFile(imgupload, a) {
- if (!imgupload) {
- return;
- }
- fileReader.readAsDataUrl(imgupload, a).then(function (result) {
- // console.log(result)
- a.imgshows1 = [result];
- var file = imgupload;
- a.uploadimgs1 = [file]; //这里是放着传给后台的数据file,下面controller的时候会有
- console.log(a.imgshows1, a.uploadimgs1);
- if (a.imgshows1.length < 1) {
- $("#upupgogo1").show();
- } else {
- $("#upupgogo1").hide();
- }
- });
- }
- }
- // 添加
- a.change1 = function (event) {
- a.isEdit1 = true;
- var element = $(".upinp1");
- model1Setter(a, element[0].files[0]);
- //附件预览
- a.imgupload1 = event.files[0];
- getFile(a.imgupload1, a);
- //获得预览图地址并且把file对象放入上传合集内
- function getFile(imgupload, a) {
- if (!imgupload) {
- return;
- }
- fileReader.readAsDataUrl(imgupload, a).then(function (result) {
- // console.log(result)
- a.imgshows1 = [result];
- var file = document.querySelector("#upupgogo1 input[type=file]").files[0];
- a.uploadimgs1 = [file]; //这里是放着传给后台的数据file,下面controller的时候会有
- console.log(a.imgshows1, a.uploadimgs1);
- if (a.imgshows1.length < 1) {
- $("#upupgogo1").show();
- } else {
- $("#upupgogo1").hide();
- }
- });
- }
- };
- // 删除
- a.uploadimg_del1 = function (index, imgs) {
- console.log(index, imgs);
- a.isEdit1 = true;
- a.imgshows1.splice(index, 1);
- a.uploadimgs1.splice(index, 1);
- a.uploader1.queue.shift();
- if (a.imgshows1.length < 1) {
- $("#upupgogo1").show();
- } else {
- $("#upupgogo1").hide();
- }
- document.querySelector("#upupgogo1 input[type=file]").value = null;
- };
- //获取字典列表
- a.wxincident_degreeList = [];
- a.incident_degreeList = [];
- a.searchList = {
- autoIncidentDegree: null,
- autoWechatDegree: null,
- }
- a.getDictionary = function(type, v){
- api_wechatfile.getDictionary({ key: type, type: "list" }).then(res => {
- a[type + 'List'] = res || [];
- if(v){
- if (v.keyconfig == 'autoIncidentDegree') {
- a.searchList.autoIncidentDegree = a[type + 'List'].find(item => item.id == v.valueconfig);
- }
- if (v.keyconfig == 'autoWechatDegree') {
- a.searchList.autoWechatDegree = a[type + 'List'].find(item => item.id == v.valueconfig);
- }
- }
- })
- .catch(err => {
- console.log(err)
- })
- }
- // 图片favicon上传----end
- //保存
- a.savesystem = function () {
- var arr = {};
- arr.systemConfiguration = [];
- angular.forEach(a.baseConfig, function (v) {
- if (v.keyconfig == 'pwd' || v.keyconfig == 'conversationSeconds' || v.keyconfig == 'systemName' || v.keyconfig == 'largeScreenName') {
- arr.systemConfiguration.push(v);//用户默认密码,登录有效时长
- }
- })
- angular.forEach(a.linkConfig, function (v) {
- arr.systemConfiguration.push(v);
- })
- arr.systemConfiguration.push(a.repairMain);//报修主体
- arr.systemConfiguration.push(a.ifCreate);//自动建单
- arr.systemConfiguration.push(a.reqHasCategory);//是否选择故障现象
- arr.systemConfiguration.push(a.incidentWithConsumable);//是否需要绑定耗材
- let autoWechatDegree = a.myData.find(v => v.keyconfig == 'autoWechatDegree');
- if(a.searchList.autoWechatDegree){
- autoWechatDegree.valueconfig = a.searchList.autoWechatDegree.id.toString();
- }else{
- autoWechatDegree.valueconfig = '';
- }
- arr.systemConfiguration.push(autoWechatDegree);
- let autoIncidentDegree = a.myData.find(v => v.keyconfig == 'autoIncidentDegree');
- if(a.searchList.autoIncidentDegree){
- autoIncidentDegree.valueconfig = a.searchList.autoIncidentDegree.id.toString();
- }else{
- autoIncidentDegree.valueconfig = '';
- }
- arr.systemConfiguration.push(autoIncidentDegree);
- arr.systemConfiguration.push(a.wxIncidentWithCmdb);//是否需要绑定资产
- arr.systemConfiguration.push(a.ifWorking);//是否开通上下班
- arr.systemConfiguration.push(a.integralMechanism);//积分机制
- arr.systemConfiguration.push(a.ifRoom);//是否增加房间号选择
- arr.systemConfiguration.push(a.requesterLgoinType);//保修人登录方式
- arr.systemConfiguration.push(a.autoCloseIncidentHour);//自动关单小时
- console.log(arr,99999);
- t.isMask = true;
- var _t = t;
- var hospitalConfig = Object.values(a.hospitalObj);
- api_simple.addListData('hospitalConfig', hospitalConfig).then(function(result){
- if(result.status == 200){
- g.addData("systemConfiguration", arr).then(function (t) {
- if (t.status == 200) {
- //获取报修主体
- api_is_category.isCategory({ "idx": 0, "sum": 1000 })
- .then(function (res) {
- _t.isMask = false;
- if (res.status == 200) {
- //存储报修主体到缓存
- var list = res.list;
- list.forEach(v => {
- switch (v.keyconfig) {
- case "repairMain": //报修主体
- sessionStorage.setItem("repair_main", JSON.stringify(v));
- break;
- case "incidentWithConsumable": //是否绑定耗材
- sessionStorage.setItem("incidentWithConsumable", v.valueconfig);
- break;
- case "wxIncidentWithCmdb": //是否绑定资产
- sessionStorage.setItem("wxIncidentWithCmdb", v.valueconfig);
- break;
- case "ifRoom": //是否增加房间号选择
- sessionStorage.setItem("ifRoom", v.valueconfig);
- break;
- case "integralMechanism": //积分机制
- sessionStorage.setItem("integralMechanism", v.valueconfig);
- break;
- }
- });
- o.swal({
- title: "保存成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- })
- if (a.uploader && a.uploadimgs.length && a.isEdit) {
- // 有图片
- a.uploader.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, _t.getSession());
- item.url = api_bpm_domain.uploadAttachmentJryModel('sysLogo', 777).getRequestedUrl();
- a.isEdit = false;
- item.formData = [{ 'fileName': item.file.name }];
- };
- a.uploader.uploadAll();
- a.uploader.onCompleteAll = function(){
- if (a.uploader1 && a.uploadimgs1.length && a.isEdit1) {
- // 有图片
- a.uploader1.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, _t.getSession());
- item.url = api_bpm_domain.uploadAttachmentJryModel('faviconLogo', 777).getRequestedUrl();
- a.isEdit1 = false;
- item.formData = [{ 'fileName': item.file.name }];
- };
- a.uploader1.uploadAll();
- a.uploader1.onCompleteAll = function(){
- a.refreshData("expand-right", f);
- }
- }else{
- a.refreshData("expand-right", f);
- }
- }
- }else{
- if (a.uploader1 && a.uploadimgs1.length && a.isEdit1) {
- // 有图片
- a.uploader1.onBeforeUploadItem = function(item) {
- angular.extend(item.headers, _t.getSession());
- item.url = api_bpm_domain.uploadAttachmentJryModel('faviconLogo', 777).getRequestedUrl();
- a.isEdit1 = false;
- item.formData = [{ 'fileName': item.file.name }];
- };
- a.uploader1.uploadAll();
- a.uploader1.onCompleteAll = function(){
- a.refreshData("expand-right", f);
- }
- }else{
- a.refreshData("expand-right", f);
- }
- }
- }
- })
- .catch(function (err) {
- _t.isMask = false;
- console.log(err)
- })
- } else {
- _t.isMask = false;
- o.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- })
- }
- })
- }else{
- _t.isMask = false;
- o.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- })
- }
- })
- .catch(function (err) {
- _t.isMask = false;
- console.log(err)
- })
- }
- a.ldloading = {}
- a.refreshData = function (t, n) {
- a.ldloading[t.replace("-", "_")] = !0;
- angular.isUndefined(n) && (n = f);
- a.myData = [];
- g.fetchDataList("systemConfiguration", n).then(function (n) {
- if (n.status == 200) {
- var e = c.stripRestangular(n);
- a.myData = e.list, a.ldloading[t.replace("-", "_")] = !1
- console.log(a.myData);
- a.baseConfig = [];//基本配置
- a.cacheConfig = [];//缓存配置
- a.linkConfig = [];//链接配置
- a.repairMain = {};//报修主体
- console.log(a.myData,77777)
- angular.forEach(a.myData, function (v, i) {
- if (v.keyconfig == 'pwd' || v.keyconfig == 'conversationSeconds' || v.keyconfig == 'formUri' || v.keyconfig == 'localhost' || v.keyconfig == 'verificationPath' || v.keyconfig == 'docpath' || v.keyconfig == 'systemName' || v.keyconfig == 'largeScreenName') {
- a.baseConfig.push(v);//基本配置
- }
- if (v.keyconfig == 'userRedisIp' || v.keyconfig == 'userRedisPort') {
- a.cacheConfig.push(v);//缓存配置
- }
- if (v.keyconfig == 'wxBxQuestions' || v.keyconfig == 'wxGuide' || v.keyconfig == 'wxClQuestions') {
- a.linkConfig.push(v);//链接配置
- }
- if (v.keyconfig == 'repairMain') {
- a.repairMain = v;//报修主体
- }
- if (v.keyconfig == 'ifCreate') {
- a.ifCreate = v;//自动建单
- }
- if (v.keyconfig == 'reqHasCategory') {
- a.reqHasCategory = v;//是否选择故障现象
- }
- if (v.keyconfig == 'incidentWithConsumable') {
- a.incidentWithConsumable = v;//是否需要绑定耗材
- }
- if (v.keyconfig == 'autoIncidentDegree') {
- a.getDictionary('incident_degree', v);
- }
- if (v.keyconfig == 'autoWechatDegree') {
- a.getDictionary('wxincident_degree', v);
- }
- if (v.keyconfig == 'wxIncidentWithCmdb') {
- a.wxIncidentWithCmdb = v;//是否需要绑定资产
- }
- if (v.keyconfig == 'ifWorking') {
- a.ifWorking = v;//是否开通上下班
- }
- if (v.keyconfig == 'integralMechanism') {
- a.integralMechanism = v;//积分机制
- }
- if (v.keyconfig == 'ifRoom') {
- a.ifRoom = v;//是否增加房间号选择
- }
- if (v.keyconfig == 'requesterLgoinType') {
- a.requesterLgoinType = v;//报修人登录方式
- }
- if (v.keyconfig == 'autoCloseIncidentHour') {
- v.valueconfig = parseFloat(v.valueconfig)
- a.autoCloseIncidentHour = v;//自动关单小时
- }
- })
- }else{
- console.log(n.status);
- }
- }, function () {
- a.ldloading[t.replace("-", "_")] = !1
- });
- api_simple.fetchDataList("hospitalConfig", {"idx":0,"sum":100,"hospitalConfig":{"hosId":a.branchId}}).then(function (result) {
- if(result.status = 200){
- a.hospitalConfig = result.list || [];
- a.hospitalConfig.forEach(function(v){
- a.hospitalObj[v.key] = v;
- })
- console.log(a.hospitalObj);
- }
- })
- // 图片回显
- api_login.getSysNameAndLogo().then(function (res) {
- res.logo && a.getDetail(location.origin + '/file' + res.logo);
- res.favicon && a.getDetail1(location.origin + '/file' + res.favicon);
- });
- }
- a.refreshData("expand-right", f)
- }]);
|