|
@@ -138,8 +138,10 @@ $(document).ready(() => {
|
|
|
$('a[aria-controls="edit-user2"]').on('click', function () {
|
|
|
$('#edit-user2 input:radio').prop('checked', false);
|
|
|
$('#edit-user2 input:checkbox').prop('checked', false);
|
|
|
+ $('#sign_permission').hide();
|
|
|
const account = $(this).data('account');
|
|
|
$('#edit-user2 input[name="id"]').val(account.id);
|
|
|
+ $('#edit-user2 input[name="unit_sign_path"]').val(account.unit_sign_path);
|
|
|
// 权限赋值
|
|
|
if (account.permission !== '') {
|
|
|
const permission = JSON.parse(account.permission);
|
|
@@ -162,6 +164,9 @@ $(document).ready(() => {
|
|
|
} else if (allPermission[pm].type === 'radio') {
|
|
|
$('#edit-user2 input:radio[id="' + pm + '_' + permission[pm] + '"]').prop('checked', true);
|
|
|
}
|
|
|
+ if (pm === 'other' && permission[pm].indexOf('1') !== -1) {
|
|
|
+ $('#sign_permission').show();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// 协作赋值
|
|
@@ -185,6 +190,56 @@ $(document).ready(() => {
|
|
|
$('#edit-user2 input[name="cooperation"]').attr('disabled', true);
|
|
|
}
|
|
|
}
|
|
|
+ if ($(this).attr('id') === 'other_1') {
|
|
|
+ if ($(this).is(':checked')) {
|
|
|
+ $('#sign_permission').show();
|
|
|
+ $('#sign_permission').click();
|
|
|
+ } else {
|
|
|
+ $('#sign_permission').hide();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#sign_permission').on('click', function () {
|
|
|
+ const uid = $('#edit-user2 input[name="id"]').val();
|
|
|
+ if (!uid) {
|
|
|
+ toastr.error('请先选择用户');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const user = _.find(accountData, { id: parseInt(uid) });
|
|
|
+ if (!user) {
|
|
|
+ toastr.error('用户不存在');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let html = '';
|
|
|
+ if (user.company) {
|
|
|
+ const unit = _.find(unitList, { name: user.company });
|
|
|
+ const unit_sign_path = $('#edit-user2 input[name="unit_sign_path"]').val();
|
|
|
+ if (unit) {
|
|
|
+ const paths = unit.sign_path ? unit.sign_path.split('&%&') : [];
|
|
|
+ if (paths.length > 0) {
|
|
|
+ console.log(paths);
|
|
|
+ for (const sp of paths) {
|
|
|
+ const checked = unit_sign_path && unit_sign_path.indexOf(sp) !== -1 ? 'checked' : '';
|
|
|
+ html += '<div class="col-3 text-center my-2"><img src="'+ fujianOssPath + sp +'" width="120">' +
|
|
|
+ '<div class="w-100 mt-2"><input type="checkbox" name="signpath[]" '+ (checked ? 'checked' : '') +' data-path="' + sp + '" />' +
|
|
|
+ '</div></div>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#unit-sign').html(html);
|
|
|
+ $('#sign_permission_modal').modal('show');
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#set_unit_sign').on('click', function () {
|
|
|
+ $('#sign_permission_modal').modal('hide');
|
|
|
+ const uid = $('#edit-user2 input[name="id"]').val();
|
|
|
+ const signPaths = [];
|
|
|
+ $('#unit-sign input[name="signpath[]"]:checked').each(function () {
|
|
|
+ signPaths.push($(this).data('path'));
|
|
|
+ });
|
|
|
+ $('#edit-user2 input[name="unit_sign_path"]').val(signPaths.join('&%&'));
|
|
|
});
|
|
|
|
|
|
// 解绑第三方平台
|
|
@@ -297,6 +352,20 @@ $(document).ready(() => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ $('#unit_user_permission').change(function () {
|
|
|
+ const val_name = 'sign_permission';
|
|
|
+ let val = $(this).is(':checked') ? 1 : 0;
|
|
|
+ if (!oneUnit) {
|
|
|
+ toastr.error('所选单位有误,请重新选择');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(oneUnit[val_name] !== val) {
|
|
|
+ postData('/setting/user/unit/save', {type: 'update', id: oneUnit.id, val_name, val}, function (result) {
|
|
|
+ oneUnit[val_name] = val;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
$('#one_unit textarea').blur(function () {
|
|
|
const val_name = $(this).data('name');
|
|
|
let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
|
|
@@ -354,6 +423,14 @@ $(document).ready(() => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ $('#mseal').on('shown.bs.modal', function () {
|
|
|
+ if (!oneUnit) {
|
|
|
+ toastr.error('所选单位有误,请重新选择');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ makeManageSignHtml(oneUnit.sign_path);
|
|
|
+ });
|
|
|
+
|
|
|
// 删除单位
|
|
|
$('#delete-unit').click(function () {
|
|
|
if (!oneUnit) {
|
|
@@ -371,40 +448,82 @@ $(document).ready(() => {
|
|
|
toastr.error('所选单位有误,请重新选择');
|
|
|
return false;
|
|
|
}
|
|
|
- const file = this.files[0];
|
|
|
- const ext = file.name.toLowerCase().split('.').splice(-1)[0];
|
|
|
- const imgStr = /(jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG)$/;
|
|
|
- if (!imgStr.test(ext)) {
|
|
|
- toastr.error('请上传正确的图片格式文件');
|
|
|
- return
|
|
|
+ const files = Array.from(this.files)
|
|
|
+ const valiData = files.map(v => {
|
|
|
+ const ext = v.name.substring(v.name.lastIndexOf('.') + 1)
|
|
|
+ return {
|
|
|
+ size: v.size,
|
|
|
+ ext
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (validateFiles(valiData)) {
|
|
|
+ if (files.length) {
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('id', oneUnit.id);
|
|
|
+ files.forEach(file => {
|
|
|
+ formData.append('name', file.name);
|
|
|
+ formData.append('size', file.size);
|
|
|
+ formData.append('file', file);
|
|
|
+ });
|
|
|
+ postDataWithFile('/setting/user/unit/upload', formData, function (result) {
|
|
|
+ oneUnit.sign_path = result.sign_path;
|
|
|
+ makeSignHtml(oneUnit.sign_path);
|
|
|
+ $('#sign-upload').val('');
|
|
|
+ toastr.success('上传成功');
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- if ($(this).val()) {
|
|
|
- const formData = new FormData();
|
|
|
- formData.append('file', this.files[0]);
|
|
|
- formData.append('id', oneUnit.id);
|
|
|
- postDataWithFile('/setting/user/unit/upload', formData, function (result) {
|
|
|
- const html = '<img src="'+ fujianOssPath + result.sign_path +'" width="120">';
|
|
|
- $('#sign-show').html(html);
|
|
|
- $('#sign-upload').val('');
|
|
|
- oneUnit.sign_path = result.sign_path;
|
|
|
- $('#upload-sign').hide();
|
|
|
- $('#delete-sign').show();
|
|
|
- toastr.success('上传成功');
|
|
|
- });
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#manage-sign-upload').change(function () {
|
|
|
+ if (!oneUnit) {
|
|
|
+ toastr.error('所选单位有误,请重新选择');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const files = Array.from(this.files)
|
|
|
+ const valiData = files.map(v => {
|
|
|
+ const ext = v.name.substring(v.name.lastIndexOf('.') + 1)
|
|
|
+ return {
|
|
|
+ size: v.size,
|
|
|
+ ext
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (validateFiles(valiData)) {
|
|
|
+ if (files.length) {
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('id', oneUnit.id);
|
|
|
+ files.forEach(file => {
|
|
|
+ formData.append('name', file.name);
|
|
|
+ formData.append('size', file.size);
|
|
|
+ formData.append('file', file);
|
|
|
+ });
|
|
|
+ postDataWithFile('/setting/user/unit/upload', formData, function (result) {
|
|
|
+ oneUnit.sign_path = result.sign_path;
|
|
|
+ makeManageSignHtml(oneUnit.sign_path);
|
|
|
+ makeSignHtml(oneUnit.sign_path);
|
|
|
+ $('#manage-sign-upload').val('');
|
|
|
+ toastr.success('上传成功');
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 移除签章
|
|
|
- $('#delete-sign').click(function () {
|
|
|
+ $('body').on('click', '#manage-unit-sign .delete-sign', function () {
|
|
|
if (!oneUnit) {
|
|
|
toastr.error('所选单位有误,请重新选择');
|
|
|
return false;
|
|
|
}
|
|
|
- postData('/setting/user/unit/save', { type: 'del-sign', id: oneUnit.id }, function (result) {
|
|
|
- $('#sign-show').html('');
|
|
|
+ const delPath = $(this).attr('data-path');
|
|
|
+ if (!delPath) {
|
|
|
+ toastr.error('所选签章有误,请重新选择');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ postData('/setting/user/unit/save', { type: 'del-sign', id: oneUnit.id, path: delPath }, function (result) {
|
|
|
+ oneUnit.sign_path = result;
|
|
|
+ makeManageSignHtml(oneUnit.sign_path);
|
|
|
+ makeSignHtml(oneUnit.sign_path);
|
|
|
toastr.warning('已移除');
|
|
|
- oneUnit.sign_path = null;
|
|
|
- $('#upload-sign').show();
|
|
|
$('#delete-sign').hide();
|
|
|
})
|
|
|
});
|
|
@@ -535,6 +654,29 @@ function checkPasswordForm() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function makeManageSignHtml(signPath) {
|
|
|
+ const paths = signPath ? signPath.split('&%&') : [];
|
|
|
+ let html = '';
|
|
|
+ if (paths.length > 0) {
|
|
|
+ for (const sp of paths) {
|
|
|
+ html += '<div class="col-3 text-center my-2"><img src="'+ fujianOssPath + sp +'" width="120"><div class="w-100"><button class="btn btn-sm btn-outline-danger delete-sign" data-path="' + sp + '">移除</button></div></div>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $('#manage-unit-sign').html(html);
|
|
|
+}
|
|
|
+
|
|
|
+function makeSignHtml(signPath) {
|
|
|
+ const paths = signPath ? signPath.split('&%&') : [];
|
|
|
+ let html = '';
|
|
|
+ if (paths.length > 0) {
|
|
|
+ for (const sp of paths.slice(0, 5)) {
|
|
|
+ html += '<img src="' + fujianOssPath + sp + '" width="120" class="mr-1">';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#sign-show').html(html);
|
|
|
+}
|
|
|
+
|
|
|
function setUnitRightHtml(id) {
|
|
|
const one = _.find(unitList, { id });
|
|
|
if (one) {
|
|
@@ -548,16 +690,15 @@ function setUnitRightHtml(id) {
|
|
|
$('#unit_basic').val(one.basic);
|
|
|
$('#unit_type').val(one.type);
|
|
|
if(one.sign_path) {
|
|
|
- $('#sign-show').html('<img src="' + fujianOssPath + one.sign_path + '" width="120">');
|
|
|
- $('#delete-sign').show();
|
|
|
- $('#upload-sign').hide();
|
|
|
+ makeSignHtml(one.sign_path);
|
|
|
+ // $('#upload-sign').hide();
|
|
|
} else {
|
|
|
$('#sign-show').html('');
|
|
|
- $('#delete-sign').hide();
|
|
|
- $('#upload-sign').show();
|
|
|
+ // $('#upload-sign').show();
|
|
|
}
|
|
|
oneUnit = one;
|
|
|
$('#add_user_company').val(one.name);
|
|
|
+ $('#unit_user_permission').prop('checked', !!oneUnit.sign_permission);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -626,6 +767,25 @@ function checkUserForm(status) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function validateFiles(files) {
|
|
|
+ if (files.length > 10) {
|
|
|
+ toastr.error('至多同时上传10个文件');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return files.every(file => {
|
|
|
+ if (file.size > 1024 * 1024 * 50) {
|
|
|
+ toastr.error('文件大小限制为50MB');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ const imgStr = /(jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG)$/;
|
|
|
+ if (!imgStr.test(file.ext)) {
|
|
|
+ toastr.error('请上传正确的图片格式文件');
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* 表单检测
|
|
|
*/
|