From e64d8b88b4c177360874f5d6ea46d67f8495cdfc Mon Sep 17 00:00:00 2001
From: mrzcc <121184950@qq.com>
Date: 星期一, 17 二月 2020 18:40:24 +0800
Subject: [PATCH] 员工select2
---
WebService/src/main/resources/components/ownerPackage/edit-owner/editOwner.js | 207 ++++++++++++++++++++++++++++++---------------------
1 files changed, 122 insertions(+), 85 deletions(-)
diff --git a/WebService/src/main/resources/components/ownerPackage/edit-owner/editOwner.js b/WebService/src/main/resources/components/ownerPackage/edit-owner/editOwner.js
index 4533b5f..8508486 100644
--- a/WebService/src/main/resources/components/ownerPackage/edit-owner/editOwner.js
+++ b/WebService/src/main/resources/components/ownerPackage/edit-owner/editOwner.js
@@ -1,150 +1,168 @@
-(function(vc){
-
+(function (vc) {
+ //var _fileUrl = 'https://hc.demo.winqi.cn/callComponent/download/getFile/fileByObjId';
+ var _fileUrl = '/callComponent/download/getFile/fileByObjId';
vc.extends({
propTypes: {
- notifyLoadDataComponentName:vc.propTypes.string
+ notifyLoadDataComponentName: vc.propTypes.string,
+ componentTitle: vc.propTypes.string // 缁勪欢鍚嶇О
},
- data:{
- editOwnerInfo:{
- ownerId:'',
- memberId:'',
- name:'',
- age:'',
- link:'',
- sex:'',
- remark:'',
- ownerPhoto:'',
- videoPlaying:false
+ data: {
+ editOwnerInfo: {
+ componentTitle: $props.componentTitle,
+ ownerId: '',
+ memberId: '',
+ ownerTypeCd: '',
+ name: '',
+ age: '',
+ link: '',
+ sex: '',
+ remark: '',
+ ownerPhoto: '',
+ idCard: '',
+ videoPlaying: false
}
},
- _initMethod:function(){
+ _initMethod: function () {
- },
- _initEvent:function(){
- vc.on('editOwner','openEditOwnerModal',function(_owner){
- vc.copyObject(_owner,vc.component.editOwnerInfo);
+ },
+ _initEvent: function () {
+ vc.on('editOwner', 'openEditOwnerModal', function (_owner) {
+ vc.copyObject(_owner, vc.component.editOwnerInfo);
//鏍规嵁memberId 鏌ヨ 鐓х墖淇℃伅
- vc.component.editOwnerInfo.ownerPhoto = "https://hc.demo.winqi.cn/callComponent/download/getFileByObjId/file?objId="+
- vc.component.editOwnerInfo.memberId +"&communityId="+vc.getCommunitys().communityId;
+ vc.component.editOwnerInfo.ownerPhoto = _fileUrl + "?objId=" +
+ vc.component.editOwnerInfo.memberId + "&communityId=" + vc.getCurrentCommunity().communityId + "&fileTypeCd=10000&time=" + new Date();
$('#editOwnerModel').modal('show');
vc.component._initAddOwnerMediaForEdit();
});
},
- methods:{
- editOwnerValidate(){
+ methods: {
+ editOwnerValidate: function () {
return vc.validate.validate({
- editOwnerInfo:vc.component.editOwnerInfo
- },{
- 'editOwnerInfo.name':[
+ editOwnerInfo: vc.component.editOwnerInfo
+ }, {
+ 'editOwnerInfo.name': [
{
- limit:"required",
- param:"",
- errInfo:"鍚嶇О涓嶈兘涓虹┖"
+ limit: "required",
+ param: "",
+ errInfo: "鍚嶇О涓嶈兘涓虹┖"
},
{
- limit:"maxin",
- param:"2,10",
- errInfo:"鍚嶇О闀垮害蹇呴』鍦�2浣嶈嚦10浣�"
+ limit: "maxin",
+ param: "2,10",
+ errInfo: "鍚嶇О闀垮害蹇呴』鍦�2浣嶈嚦10浣�"
},
],
- 'editOwnerInfo.age':[
+ 'editOwnerInfo.age': [
{
- limit:"required",
- param:"",
- errInfo:"骞撮緞涓嶈兘涓虹┖"
+ limit: "required",
+ param: "",
+ errInfo: "骞撮緞涓嶈兘涓虹┖"
},
{
- limit:"num",
- param:"",
- errInfo:"骞撮緞涓嶆槸鏈夋晥鐨勬暟瀛�"
+ limit: "num",
+ param: "",
+ errInfo: "骞撮緞涓嶆槸鏈夋晥鐨勬暟瀛�"
},
],
- 'editOwnerInfo.sex':[
+ 'editOwnerInfo.sex': [
{
- limit:"required",
- param:"",
- errInfo:"鎬у埆涓嶈兘涓虹┖"
+ limit: "required",
+ param: "",
+ errInfo: "鎬у埆涓嶈兘涓虹┖"
}
],
- 'editOwnerInfo.link':[
+ 'editOwnerInfo.idCard': [
{
- limit:"required",
- param:"",
- errInfo:"鎵嬫満鍙蜂笉鑳戒负绌�"
- },
- {
- limit:"phone",
- param:"",
- errInfo:"涓嶆槸鏈夋晥鐨勬墜鏈哄彿"
+ limit: "maxLength",
+ param: "18",
+ errInfo: "韬唤璇侀暱搴︿笉鑳借秴杩�200浣�"
}
],
- 'editOwnerInfo.remark':[
+ 'editOwnerInfo.link': [
+ {
+ limit: "required",
+ param: "",
+ errInfo: "鎵嬫満鍙蜂笉鑳戒负绌�"
+ },
+ {
+ limit: "phone",
+ param: "",
+ errInfo: "涓嶆槸鏈夋晥鐨勬墜鏈哄彿"
+ }
+ ],
+ 'editOwnerInfo.remark': [
{
- limit:"maxLength",
- param:"200",
- errInfo:"澶囨敞闀垮害涓嶈兘瓒呰繃200浣�"
+ limit: "maxLength",
+ param: "200",
+ errInfo: "澶囨敞闀垮害涓嶈兘瓒呰繃200浣�"
}
]
});
},
- editOwnerMethod:function(){
+ editOwnerMethod: function () {
- if(!vc.component.editOwnerValidate()){
- vc.message(vc.validate.errInfo);
+ if (!vc.component.editOwnerValidate()) {
+ vc.toast(vc.validate.errInfo);
- return ;
+ return;
}
vc.component.editOwnerInfo.communityId = vc.getCurrentCommunity().communityId;
+
+ //缂栬緫鏃� ownerPhoto 涓唴瀹逛笉鏄収鐗囧唴瀹癸紝鍒欐竻绌�
+ if (vc.component.editOwnerInfo.ownerPhoto.indexOf(_fileUrl) != -1) {
+ vc.component.editOwnerInfo.ownerPhoto = "";
+ }
vc.http.post(
'editOwner',
'changeOwner',
JSON.stringify(vc.component.editOwnerInfo),
{
- emulateJSON:true
- },
- function(json,res){
+ emulateJSON: true
+ },
+ function (json, res) {
//vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
- if(res.status == 200){
+ if (res.status == 200) {
//鍏抽棴model
$('#editOwnerModel').modal('hide');
vc.component.clearEditOwnerInfo();
- vc.emit($props.notifyLoadDataComponentName,'listOwnerData',{});
+ vc.emit($props.notifyLoadDataComponentName, 'listOwnerData', {});
- return ;
+ return;
}
vc.message(json);
- },
- function(errInfo,error){
+ },
+ function (errInfo, error) {
console.log('璇锋眰澶辫触澶勭悊');
vc.message(errInfo);
- });
+ });
},
- clearEditOwnerInfo:function(){
+ clearEditOwnerInfo: function () {
vc.component.editOwnerInfo = {
- ownerId:'',
- memberId:'',
- name:'',
- age:'',
- link:'',
- sex:'',
- remark:'',
- ownerPhoto:'',
- videoPlaying:false
+ ownerId: '',
+ memberId: '',
+ name: '',
+ age: '',
+ link: '',
+ sex: '',
+ remark: '',
+ idCard: '',
+ ownerPhoto: '',
+ videoPlaying: false
};
},
- _editUserMedia:function() {
+ _editUserMedia: function () {
return navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia || null;
},
- _initAddOwnerMediaForEdit:function () {
- if(vc.component._editUserMedia()){
+ _initAddOwnerMediaForEdit: function () {
+ if (vc.component._editUserMedia()) {
vc.component.editOwnerInfo.videoPlaying = false;
var constraints = {
video: true,
@@ -165,11 +183,11 @@
console.log("ERROR");
console.log(error);
});
- }else{
+ } else {
console.log("鍒濆鍖栬棰戝け璐�");
}
},
- _takePhotoForEdit:function () {
+ _takePhotoForEdit: function () {
if (vc.component.editOwnerInfo.videoPlaying) {
var canvas = document.getElementById('canvasForEdit');
var video = document.getElementById('ownerPhotoForEdit');
@@ -180,7 +198,26 @@
vc.component.editOwnerInfo.ownerPhoto = data;
//document.getElementById('photo').setAttribute('src', data);
}
- }
+ },
+ _uploadEditPhoto: function (event) {
+ $("#uploadEditOwnerPhoto").trigger("click")
+ },
+ _chooseEditPhoto: function (event) {
+ var photoFiles = event.target.files;
+ if (photoFiles && photoFiles.length > 0) {
+ // 鑾峰彇鐩墠涓婁紶鐨勬枃浠�
+ var file = photoFiles[0];// 鏂囦欢澶у皬鏍¢獙鐨勫姩浣�
+ if (file.size > 1024 * 1024 * 1) {
+ vc.toast("鍥剧墖澶у皬涓嶈兘瓒呰繃 2MB!")
+ return false;
+ }
+ var reader = new FileReader(); //鏂板缓FileReader瀵硅薄
+ reader.readAsDataURL(file); //璇诲彇涓篵ase64
+ reader.onloadend = function (e) {
+ vc.component.editOwnerInfo.ownerPhoto = reader.result;
+ }
+ }
+ },
}
});
--
Gitblit v1.8.0