diff --git a/package.json b/package.json index 0ac33a521..ae4e08920 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "stylus-loader": "^6.2.0", "tinymce": "^5.10.3", "tui-calendar-hi": "^1.15.1-5", - "view-design-hi": "^4.7.0-29", + "view-design-hi": "^4.7.0-30", "vue": "^2.6.14", "vue-clipboard2": "^0.3.3", "vue-kityminder-ggg": "^1.3.10", diff --git a/resources/assets/js/components/RightBottom.vue b/resources/assets/js/components/RightBottom.vue index d0e77af52..928f7cbf0 100644 --- a/resources/assets/js/components/RightBottom.vue +++ b/resources/assets/js/components/RightBottom.vue @@ -129,7 +129,7 @@ export default { if (this.isNotServer()) { return; } - axios.get($A.apiUrl('../version')).then(({status, data}) => { + axios.get($A.apiUrl('system/version')).then(({status, data}) => { if (status === 200) { this.apiVersion = data.version || '' // 检查接口版本 diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js index 345c8984d..1c0e645fe 100755 --- a/resources/assets/js/functions/web.js +++ b/resources/assets/js/functions/web.js @@ -441,15 +441,29 @@ if (typeof config === "string") config = {title:config}; let inputId = "modalInput_" + $A.randomString(6); const onOk = () => { - if (typeof config.onOk === "function") { - if (config.onOk(config.value, () => { - $A.Modal.remove(); - }) === true) { - $A.Modal.remove(); + return new Promise((resolve, reject) => { + if (!config.onOk) { + reject() // 没有返回:取消等待 + return } - } else { - $A.Modal.remove(); - } + const call = config.onOk(config.value); + if (!call) { + resolve() // 返回无内容:关闭弹窗 + return + } + if (call.then) { + call.then(msg => { + msg && $A.messageSuccess(msg) + resolve() + }).catch(err => { + err && $A.messageError(err) + reject() + }); + } else { + typeof call === "string" && $A.messageError(call) + reject() + } + }) }; const onCancel = () => { if (typeof config.onCancel === "function") { @@ -502,6 +516,35 @@ setTimeout(() => { $A.modalConfirm(config) }, millisecond); return; } + config = $A.modalConfig(config); + if (config.loading) { + const {onOk} = config; + config.onOk = () => { + return new Promise((resolve, reject) => { + if (!onOk) { + reject() // 没有返回:取消等待 + return + } + const call = onOk(); + if (!call) { + resolve() // 返回无内容:关闭弹窗 + return + } + if (call.then) { + call.then(msg => { + msg && $A.messageSuccess(msg) + resolve() + }).catch(err => { + err && $A.messageError(err) + reject() + }); + } else { + typeof call === "string" && $A.messageError(call) + reject() + } + }) + } + } $A.Modal.confirm($A.modalConfig(config)); }, diff --git a/resources/assets/js/pages/login.vue b/resources/assets/js/pages/login.vue index 3dbc73a88..d25d4539e 100644 --- a/resources/assets/js/pages/login.vue +++ b/resources/assets/js/pages/login.vue @@ -302,18 +302,17 @@ export default { title: "使用 SSO 登录", value, placeholder: "请输入服务器地址", - onOk: (value, cb) => { - if (value) { - this.inputServerChack($A.trim(value)).then(cb) - } else { - this.clearServerUrl(); + onOk: (value) => { + if (!value) { + return '请输入服务器地址' } + return this.inputServerChack($A.trim(value)) } }); }, inputServerChack(value) { - return new Promise(resolve => { + return new Promise((resolve, reject) => { let url = value; if (!/\/api\/$/.test(url)) { url = url + ($A.rightExists(url, "/") ? "api/" : "/api/"); @@ -330,18 +329,12 @@ export default { }).catch(({ret, msg}) => { if (ret === -1001) { if (!/^https*:\/\//i.test(value)) { - this.inputServerChack(`http://${value}`).then(resolve); + this.inputServerChack(`http://${value}`).then(resolve).catch(reject); return; } msg = "服务器地址无效"; } - $A.modalError({ - content: msg, - onOk: () => { - setTimeout(this.inputServerUrl, 301) - } - }, 301); - resolve() + reject(msg) }); }) }, diff --git a/resources/assets/js/pages/manage/components/ProjectPanel.vue b/resources/assets/js/pages/manage/components/ProjectPanel.vue index 4af7270db..bfb2a5c7b 100644 --- a/resources/assets/js/pages/manage/components/ProjectPanel.vue +++ b/resources/assets/js/pages/manage/components/ProjectPanel.vue @@ -989,7 +989,7 @@ export default { else if (command.name) { this.updateColumn(column, { color: command.color - }); + }).catch($A.modalError); } }, @@ -999,37 +999,41 @@ export default { title: "修改列表", placeholder: "输入列表名称", onOk: (value) => { - if (value) { - this.updateColumn(column, { - name: value - }); + if (!value) { + return '列表名称不能为空' } - return true; + return this.updateColumn(column, { + name: value + }) } }); }, updateColumn(column, updata) { - if (this.columnLoad[column.id] === true) { - return; - } - this.$set(this.columnLoad, column.id, true); - // - Object.keys(updata).forEach(key => this.$set(column, key, updata[key])); - // - this.$store.dispatch("call", { - url: 'project/column/update', - data: Object.assign(updata, { - column_id: column.id, - }), - }).then(({data}) => { - this.$set(this.columnLoad, column.id, false); - this.$store.dispatch("saveColumn", data); - }).catch(({msg}) => { - this.$set(this.columnLoad, column.id, false); - this.$store.dispatch("getColumns", this.projectId).catch(() => {}) - $A.modalError(msg); - }); + return new Promise((resolve, reject) => { + if (this.columnLoad[column.id] === true) { + resolve() + return; + } + this.$set(this.columnLoad, column.id, true); + // + Object.keys(updata).forEach(key => this.$set(column, key, updata[key])); + // + this.$store.dispatch("call", { + url: 'project/column/update', + data: Object.assign(updata, { + column_id: column.id, + }), + }).then(({data}) => { + this.$set(this.columnLoad, column.id, false); + this.$store.dispatch("saveColumn", data); + resolve() + }).catch(({msg}) => { + this.$set(this.columnLoad, column.id, false); + this.$store.dispatch("getColumns", this.projectId).catch(() => {}) + reject(msg); + }); + }) }, removeColumn(column) { diff --git a/resources/assets/js/pages/manage/components/ProjectWorkflow.vue b/resources/assets/js/pages/manage/components/ProjectWorkflow.vue index 8d94f19a1..982e0ab2c 100644 --- a/resources/assets/js/pages/manage/components/ProjectWorkflow.vue +++ b/resources/assets/js/pages/manage/components/ProjectWorkflow.vue @@ -403,12 +403,12 @@ export default { $A.modalInput({ value: item.name, title: "修改名称", - placeholder: "输入流程名称", + placeholder: "请输入流程名称", onOk: (name) => { - if (name) { - this.$set(item, 'name', name); + if (!name) { + return '请输入流程名称'; } - return true; + this.$set(item, 'name', name); } }); }, @@ -429,25 +429,25 @@ export default { onAdd(data) { $A.modalInput({ title: "添加状态", - placeholder: "输入状态名称", + placeholder: "请输入状态名称", onOk: (name) => { - if (name) { - let id = $A.randNum(100000, 999999) * -1; - let turns = data.project_flow_item.map(({id}) => id) - data.project_flow_item.push({ - id, - name, - status: 'end', - turns, - userids: [], - usertype: 'add', - userlimit: 0, - }) - data.project_flow_item.some(item => { - item.turns.push(id) - }) + if (!name) { + return '请输入状态名称' } - return true; + const id = $A.randNum(100000, 999999) * -1; + const turns = data.project_flow_item.map(({id}) => id) + data.project_flow_item.push({ + id, + name, + status: 'end', + turns, + userids: [], + usertype: 'add', + userlimit: 0, + }) + data.project_flow_item.some(item => { + item.turns.push(id) + }) } }); }, diff --git a/resources/assets/js/pages/manage/components/TeamManagement.vue b/resources/assets/js/pages/manage/components/TeamManagement.vue index ecfd7bfd0..d254a7633 100644 --- a/resources/assets/js/pages/manage/components/TeamManagement.vue +++ b/resources/assets/js/pages/manage/components/TeamManagement.vue @@ -115,7 +115,7 @@ confirm placement="bottom" style="margin-left:8px" - @on-ok="operationUser(disableData)" + @on-ok="operationUser(disableData, true)" transfer>

{{$L('注意:离职操作不可逆!')}}

@@ -236,7 +236,7 @@ export default { this.operationUser({ userid: row.userid, nickname: val - }).then(cb); + }, true).finally(cb); } } }, [ @@ -258,7 +258,7 @@ export default { this.operationUser({ userid: row.userid, profession: val - }).then(cb); + }, true).finally(cb); } } }, [ @@ -292,6 +292,12 @@ export default { }, [h('div', this.$L('设为管理员'))])); } + dropdownItems.push(h('EDropdownItem', { + props: { + command: 'email', + }, + }, [h('div', this.$L('修改邮箱'))])) + dropdownItems.push(h('EDropdownItem', { props: { command: 'password', @@ -401,18 +407,34 @@ export default { dropUser(name, row) { switch (name) { + case 'email': + $A.modalInput({ + title: "修改邮箱", + placeholder: `请输入新的邮箱(${row.email})`, + onOk: (value) => { + if (!value) { + return '请输入新的邮箱地址' + } + return this.operationUser({ + userid: row.userid, + email: value + }); + } + }); + break; + case 'password': $A.modalInput({ title: "修改密码", placeholder: "请输入新的密码", onOk: (value) => { - if (value) { - this.operationUser({ - userid: row.userid, - password: value - }); + if (!value) { + return '请输入新的密码' } - return true; + return this.operationUser({ + userid: row.userid, + password: value + }); } }); break; @@ -429,8 +451,9 @@ export default { case 'cleardisable': $A.modalConfirm({ content: `你确定恢复已离职帐号【ID:${row.userid},${row.nickname}】吗?(注:此操作仅恢复帐号状态,无法恢复操作离职时移交的数据)`, + loading: true, onOk: () => { - this.operationUser({ + return this.operationUser({ userid: row.userid, type: name }); @@ -441,8 +464,9 @@ export default { case 'delete': $A.modalConfirm({ content: `你确定要删除帐号【ID:${row.userid},${row.nickname}】吗?`, + loading: true, onOk: () => { - this.operationUser({ + return this.operationUser({ userid: row.userid, type: name, }); @@ -454,13 +478,13 @@ export default { this.operationUser({ userid: row.userid, type: name - }); + }, true); break; } }, - operationUser(data) { - return new Promise((resolve) => { + operationUser(data, tipErr) { + return new Promise((resolve, reject) => { if (data.type == 'setdisable') { this.disableLoading++; } else { @@ -477,9 +501,11 @@ export default { this.disableShow = false; } }).catch(({msg}) => { - $A.modalError(msg, 301); + if (tipErr === true) { + $A.modalError(msg); + } this.getLists(); - resolve() + reject(msg) }).finally(_ => { if (data.type == 'setdisable') { this.disableLoading--; diff --git a/resources/assets/js/pages/manage/setting/components/SystemEmailSetting.vue b/resources/assets/js/pages/manage/setting/components/SystemEmailSetting.vue index eb4b37e4b..983a659be 100644 --- a/resources/assets/js/pages/manage/setting/components/SystemEmailSetting.vue +++ b/resources/assets/js/pages/manage/setting/components/SystemEmailSetting.vue @@ -163,28 +163,25 @@ export default { $A.modalInput({ title: "测试邮件", placeholder: "请输入收件人地址", - onOk: (value, cb) => { + onOk: (value) => { if (!value) { - cb() - return + return '请输入收件人地址' } if (!$A.isEmail(value)) { - $A.modalError("请输入正确的收件人地址", 301) - cb() - return + return '请输入正确的收件人地址' } - this.$store.dispatch("call", { - url: 'system/email/check', - data: Object.assign(this.formData, { - to: value - }), - }).then(({msg}) => { - $A.messageSuccess(msg) - cb() - }).catch(({msg}) => { - $A.modalError(msg, 301) - cb() - }); + return new Promise((resolve, reject) => { + this.$store.dispatch("call", { + url: 'system/email/check', + data: Object.assign(this.formData, { + to: value + }), + }).then(({msg}) => { + resolve(msg) + }).catch(({msg}) => { + reject(msg) + }); + }) } }); } diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index dbd529db2..a16d8fdb0 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -66,8 +66,8 @@ export default { dispatch("call", Object.assign(cloneParams, { checkNick: false })).then(resolve).catch(reject); - }).catch(({msg}) => { - reject({ret: -1, data, msg: msg || $A.L('请设置昵称!')}) + }).catch(err => { + reject({ret: -1, data, msg: err || $A.L('请设置昵称!')}) }); return; } @@ -425,26 +425,17 @@ export default { * @returns {Promise} */ userNickNameInput({dispatch}) { - return new Promise(function (resolve, reject) { - let callback = (cb, result) => { - if (typeof cb === "function") { - cb(); - } - if (result === true) { - setTimeout(resolve, 301) - } else { - setTimeout(_ => { - reject(result === false ? {} : {msg: result}) - }, 301) - } - } + return new Promise(function (nameResolve, nameReject) { setTimeout(_ => { $A.modalInput({ title: "设置昵称", placeholder: "请输入昵称", okText: "保存", - onOk: (value, cb) => { - if (value) { + onOk: (value) => { + if (!value) { + return '请输入昵称' + } + return new Promise((inResolve, inReject) => { dispatch("call", { url: 'users/editdata', data: { @@ -452,21 +443,16 @@ export default { }, checkNick: false, }).then(() => { - dispatch('getUserInfo').then(() => { - callback(cb, true); - }).catch(() => { - callback(cb, false); + dispatch('getUserInfo').finally(_ => { + inResolve() + nameResolve() }); }).catch(({msg}) => { - callback(cb, msg); + inReject(msg) }); - } else { - callback(cb, false); - } + }) }, - onCancel: () => { - callback(null, false); - } + onCancel: _ => setTimeout(nameReject, 301) }); }, 100) });