diff --git a/app/Http/Controllers/Api/SystemController.php b/app/Http/Controllers/Api/SystemController.php index 4e060409..416e6eb1 100755 --- a/app/Http/Controllers/Api/SystemController.php +++ b/app/Http/Controllers/Api/SystemController.php @@ -101,12 +101,16 @@ class SystemController extends AbstractController } /** - * @api {post} api/system/priority 03. 获取优先级、保存优先级 + * @api {post} api/system/priority 03. 任务优先级 * + * @apiDescription 获取任务优先级、保存任务优先级 * @apiVersion 1.0.0 * @apiGroup system * @apiName priority * + * @apiParam {String} type + * - get: 获取(默认) + * - save: 保存(限管理员) * @apiParam {Array} list 优先级数据,格式:[{name,color,days,priority}] * * @apiSuccess {Number} ret 返回状态码(1正确、0错误) @@ -145,6 +149,53 @@ class SystemController extends AbstractController return Base::retSuccess('success', $setting); } + /** + * @api {post} api/system/column/template 03. 创建项目模板 + * + * @apiDescription 获取创建项目模板、保存创建项目模板 + * @apiVersion 1.0.0 + * @apiGroup system + * @apiName column__template + * + * @apiParam {String} type + * - get: 获取(默认) + * - save: 保存(限管理员) + * @apiParam {Array} list 优先级数据,格式:[{name,columns}] + * + * @apiSuccess {Number} ret 返回状态码(1正确、0错误) + * @apiSuccess {String} msg 返回信息(错误描述) + * @apiSuccess {Object} data 返回数据 + */ + public function column__template() + { + $type = trim(Request::input('type')); + if ($type == 'save') { + User::auth('admin'); + $list = Base::getPostValue('list'); + $array = []; + if (empty($list) || !is_array($list)) { + return Base::retError('参数错误'); + } + foreach ($list AS $item) { + if (empty($item['name']) || empty($item['columns'])) { + continue; + } + $array[] = [ + 'name' => $item['name'], + 'columns' => array_values(array_filter(array_unique(explode(",", $item['columns'])))) + ]; + } + if (empty($array)) { + return Base::retError('参数为空'); + } + $setting = Base::setting('columnTemplate', $array); + } else { + $setting = Base::setting('columnTemplate'); + } + // + return Base::retSuccess('success', $setting); + } + /** * @api {get} api/system/get/info 04. 获取终端详细信息 * diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 4a2269d6..c021038d 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -21,6 +21,9 @@ class VerifyCsrfToken extends Middleware // 保存任务优先级 'api/system/priority/', + // 保存创建项目列表模板 + 'api/system/column/template/', + // 添加任务 'api/project/task/add/', diff --git a/database/migrations/2022_02_08_211051_insert_setting_column_template.php b/database/migrations/2022_02_08_211051_insert_setting_column_template.php new file mode 100644 index 00000000..40cb5acf --- /dev/null +++ b/database/migrations/2022_02_08_211051_insert_setting_column_template.php @@ -0,0 +1,40 @@ + '软件开发', + 'columns' => ['产品规划', '前端开发', '后端开发', '测试', '发布', '其他'], + ], + [ + 'name' => '产品开发', + 'columns' => ['产品计划', '正在设计', '正在研发', '测试', '准备发布', '发布成功'], + ], + ]); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + } +} diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 56e953ad..d9e814ac 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -138,9 +138,15 @@ + + + {{$L('开启')}} + {{$L('关闭')}} + +
@@ -250,6 +256,7 @@ export default { addData: { name: '', columns: '', + flow: 'open', }, addRule: {}, @@ -258,8 +265,6 @@ export default { dialogMsgSubscribe: null, - columns: [], - projectKeyValue: '', projectKeyAlready: {}, projectKeyLoading: 0, @@ -331,6 +336,7 @@ export default { 'projectTotal', 'taskId', 'wsOpenNum', + 'columnTemplate', 'themeMode', 'themeList', @@ -370,7 +376,7 @@ export default { {path: 'password', name: '密码设置'}, {path: 'clearCache', name: '清除缓存'}, {path: 'system', name: '系统设置', divided: true}, - {path: 'priority', name: '任务等级'}, + {path: 'preference', name: '偏好设置'}, {path: 'workReport', name: '工作报告', divided: true}, {path: 'allUser', name: '团队管理'}, {path: 'allProject', name: '所有项目'}, @@ -387,6 +393,15 @@ export default { } }, + columns() { + const array = $A.cloneJSON(this.columnTemplate); + array.unshift({ + name: this.$L('空白模板'), + columns: [], + }) + return array + }, + projectLists() { const {projectKeyValue, cacheProjects} = this; const data = cacheProjects.sort((a, b) => { @@ -483,16 +498,6 @@ export default { methods: { initLanguage() { - this.columns = [{ - label: this.$L('空白模板'), - value: [], - }, { - label: this.$L('软件开发'), - value: [this.$L('产品规划'), this.$L('前端开发'), this.$L('后端开发'), this.$L('测试'), this.$L('发布'), this.$L('其它')], - }, { - label: this.$L('产品开发'), - value: [this.$L('产品计划'), this.$L('正在设计'), this.$L('正在研发'), this.$L('测试'), this.$L('准备发布'), this.$L('发布成功')], - }]; this.addRule = { name: [ { required: true, message: this.$L('请填写项目名称!'), trigger: 'change' }, @@ -593,6 +598,7 @@ export default { }, onAddShow() { + this.$store.dispatch("getColumnTemplate").catch(() => {}) this.addShow = true; this.$nextTick(() => { this.$refs.projectName.focus(); @@ -643,7 +649,7 @@ export default { selectChange(index) { this.$nextTick(() => { - this.$set(this.addData, 'columns', this.columns[index].value.join(',')); + this.$set(this.addData, 'columns', this.columns[index].columns.join(',')); }) }, diff --git a/resources/assets/js/pages/manage/setting/index.vue b/resources/assets/js/pages/manage/setting/index.vue index dedabbb7..aed9061a 100644 --- a/resources/assets/js/pages/manage/setting/index.vue +++ b/resources/assets/js/pages/manage/setting/index.vue @@ -56,7 +56,7 @@ export default { if (this.userIsAdmin) { menu.push(...[ {path: 'system', name: '系统设置', divided: true}, - {path: 'priority', name: '任务等级'}, + {path: 'preference', name: '偏好设置'}, ]) } return menu; diff --git a/resources/assets/js/pages/manage/setting/preference/columnTemplate.vue b/resources/assets/js/pages/manage/setting/preference/columnTemplate.vue new file mode 100644 index 00000000..0aca2d3d --- /dev/null +++ b/resources/assets/js/pages/manage/setting/preference/columnTemplate.vue @@ -0,0 +1,120 @@ + + + diff --git a/resources/assets/js/pages/manage/setting/preference/index.vue b/resources/assets/js/pages/manage/setting/preference/index.vue new file mode 100644 index 00000000..17c770f7 --- /dev/null +++ b/resources/assets/js/pages/manage/setting/preference/index.vue @@ -0,0 +1,25 @@ + + + diff --git a/resources/assets/js/pages/manage/setting/priority.vue b/resources/assets/js/pages/manage/setting/preference/taskPriority.vue similarity index 98% rename from resources/assets/js/pages/manage/setting/priority.vue rename to resources/assets/js/pages/manage/setting/preference/taskPriority.vue index e8adb325..b08c7d79 100644 --- a/resources/assets/js/pages/manage/setting/priority.vue +++ b/resources/assets/js/pages/manage/setting/preference/taskPriority.vue @@ -1,5 +1,5 @@