feat: 新增自定义添加项目时的项目模板
This commit is contained in:
parent
ea58ed46f2
commit
fb24af1900
@ -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. 获取终端详细信息
|
||||
*
|
||||
|
@ -21,6 +21,9 @@ class VerifyCsrfToken extends Middleware
|
||||
// 保存任务优先级
|
||||
'api/system/priority/',
|
||||
|
||||
// 保存创建项目列表模板
|
||||
'api/system/column/template/',
|
||||
|
||||
// 添加任务
|
||||
'api/project/task/add/',
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class InsertSettingColumnTemplate extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$array = \App\Module\Base::setting('columnTemplate');
|
||||
if (empty($array)) {
|
||||
\App\Module\Base::setting('columnTemplate', [
|
||||
[
|
||||
'name' => '软件开发',
|
||||
'columns' => ['产品规划', '前端开发', '后端开发', '测试', '发布', '其他'],
|
||||
],
|
||||
[
|
||||
'name' => '产品开发',
|
||||
'columns' => ['产品计划', '正在设计', '正在研发', '测试', '准备发布', '发布成功'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -138,9 +138,15 @@
|
||||
</FormItem>
|
||||
<FormItem v-else :label="$L('项目模板')">
|
||||
<Select :value="0" @on-change="selectChange" :placeholder="$L('请选择模板')">
|
||||
<Option v-for="(item, index) in columns" :value="index" :key="index">{{ item.label }}</Option>
|
||||
<Option v-for="(item, index) in columns" :value="index" :key="index">{{ item.name }}</Option>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem prop="flow" :label="$L('开启工作流')">
|
||||
<RadioGroup v-model="addData.flow">
|
||||
<Radio label="open">{{$L('开启')}}</Radio>
|
||||
<Radio label="close">{{$L('关闭')}}</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div slot="footer" class="adaption">
|
||||
<Button type="default" @click="addShow=false">{{$L('取消')}}</Button>
|
||||
@ -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(','));
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -56,7 +56,7 @@ export default {
|
||||
if (this.userIsAdmin) {
|
||||
menu.push(...[
|
||||
{path: 'system', name: '系统设置', divided: true},
|
||||
{path: 'priority', name: '任务等级'},
|
||||
{path: 'preference', name: '偏好设置'},
|
||||
])
|
||||
}
|
||||
return menu;
|
||||
|
@ -0,0 +1,120 @@
|
||||
<template>
|
||||
<div class="preference-project-create">
|
||||
<Form ref="formDatum" label-width="auto" @submit.native.prevent>
|
||||
<Row class="setting-template">
|
||||
<Col span="8">{{$L('名称')}}</Col>
|
||||
<Col span="16">{{$L('列表模板')}}</Col>
|
||||
</Row>
|
||||
<Row v-for="(item, key) in formDatum" :key="key" class="setting-template">
|
||||
<Col span="8">
|
||||
<Input
|
||||
v-model="item.name"
|
||||
:maxlength="20"
|
||||
:placeholder="$L('请输入名称')"
|
||||
clearable
|
||||
@on-clear="delDatum(key)"/>
|
||||
</Col>
|
||||
<Col span="16">
|
||||
<TagInput v-model="item.columns"/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Button type="default" icon="md-add" @click="addDatum">{{$L('添加模板')}}</Button>
|
||||
</Form>
|
||||
<div class="setting-footer">
|
||||
<Button :loading="loadIng > 0" type="primary" @click="submitForm">{{$L('提交')}}</Button>
|
||||
<Button :loading="loadIng > 0" @click="resetForm" style="margin-left: 8px">{{$L('重置')}}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapState} from "vuex";
|
||||
|
||||
export default {
|
||||
name: 'PreferenceColumnTemplate',
|
||||
data() {
|
||||
return {
|
||||
loadIng: 0,
|
||||
|
||||
formDatum: [],
|
||||
|
||||
nullDatum: {
|
||||
'name': '',
|
||||
'columns': '',
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.systemSetting();
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['columnTemplate']),
|
||||
},
|
||||
|
||||
watch: {
|
||||
columnTemplate: {
|
||||
handler(data) {
|
||||
this.formDatum = $A.cloneJSON(data);
|
||||
if (this.formDatum.length === 0) {
|
||||
this.addDatum();
|
||||
}
|
||||
},
|
||||
immediate: true,
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.$refs.formDatum.validate((valid) => {
|
||||
if (valid) {
|
||||
this.systemSetting(true);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
resetForm() {
|
||||
this.formDatum = $A.cloneJSON(this.columnTemplate);
|
||||
},
|
||||
|
||||
addDatum() {
|
||||
this.formDatum.push($A.cloneJSON(this.nullDatum));
|
||||
},
|
||||
|
||||
delDatum(key) {
|
||||
this.formDatum.splice(key, 1);
|
||||
if (this.formDatum.length === 0) {
|
||||
this.addDatum();
|
||||
}
|
||||
},
|
||||
|
||||
systemSetting(save) {
|
||||
this.loadIng++;
|
||||
this.$store.dispatch("call", {
|
||||
url: 'system/column/template?type=' + (save ? 'save' : 'get'),
|
||||
method: 'post',
|
||||
data: {
|
||||
list: this.formDatum
|
||||
},
|
||||
}).then(({data}) => {
|
||||
if (save) {
|
||||
$A.messageSuccess('修改成功');
|
||||
}
|
||||
this.loadIng--;
|
||||
this.$store.state.columnTemplate = $A.cloneJSON(data).map(item => {
|
||||
if ($A.isArray(item.columns)) {
|
||||
item.columns = item.columns.join(",")
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}).catch(({msg}) => {
|
||||
if (save) {
|
||||
$A.modalError(msg);
|
||||
}
|
||||
this.loadIng--;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<div class="setting-item submit">
|
||||
<Tabs v-model="tabAction">
|
||||
<TabPane :label="$L('任务优先级')" name="priority">
|
||||
<PreferenceTaskPriority/>
|
||||
</TabPane>
|
||||
<TabPane :label="$L('新建项目模板')" name="columnTemplate">
|
||||
<PreferenceColumnTemplate/>
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import PreferenceTaskPriority from "./taskPriority";
|
||||
import PreferenceColumnTemplate from "./columnTemplate";
|
||||
export default {
|
||||
components: {PreferenceColumnTemplate, PreferenceTaskPriority},
|
||||
data() {
|
||||
return {
|
||||
tabAction: 'priority',
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="setting-item submit">
|
||||
<div class="preference-task-priority">
|
||||
<Form ref="formDatum" label-width="auto" @submit.native.prevent>
|
||||
<Row class="setting-color">
|
||||
<Col span="12">{{$L('名称')}}</Col>
|
||||
@ -47,6 +47,7 @@
|
||||
import {mapState} from "vuex";
|
||||
|
||||
export default {
|
||||
name: 'PreferenceTaskPriority',
|
||||
data() {
|
||||
return {
|
||||
loadIng: 0,
|
||||
@ -66,8 +67,6 @@ export default {
|
||||
this.systemSetting();
|
||||
},
|
||||
|
||||
|
||||
|
||||
computed: {
|
||||
...mapState(['taskPriority']),
|
||||
},
|
6
resources/assets/js/routes.js
vendored
6
resources/assets/js/routes.js
vendored
@ -52,9 +52,9 @@ export default [
|
||||
component: () => import('./pages/manage/setting/system.vue'),
|
||||
},
|
||||
{
|
||||
name: 'manage-setting-priority',
|
||||
path: 'priority',
|
||||
component: () => import('./pages/manage/setting/priority.vue'),
|
||||
name: 'manage-setting-preference',
|
||||
path: 'preference',
|
||||
component: () => import('./pages/manage/setting/preference/index.vue'),
|
||||
},
|
||||
]
|
||||
},
|
||||
|
20
resources/assets/js/store/actions.js
vendored
20
resources/assets/js/store/actions.js
vendored
@ -1623,6 +1623,26 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取添加项目列表预设数据
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
getColumnTemplate({state, dispatch}) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
dispatch("call", {
|
||||
url: 'system/column/template',
|
||||
}).then(result => {
|
||||
state.columnTemplate = result.data;
|
||||
resolve(result)
|
||||
}).catch(e => {
|
||||
console.warn(e);
|
||||
reject(e);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 保存完成任务临时表
|
||||
* @param state
|
||||
|
3
resources/assets/js/store/state.js
vendored
3
resources/assets/js/store/state.js
vendored
@ -78,6 +78,9 @@ const stateData = {
|
||||
// 任务优先级
|
||||
taskPriority: [],
|
||||
|
||||
// 项目创建列表模板
|
||||
columnTemplate: [],
|
||||
|
||||
// 列表背景色
|
||||
columnColorList: [
|
||||
{name: '默认', color: ''},
|
||||
|
45
resources/assets/sass/pages/page-setting.scss
vendored
45
resources/assets/sass/pages/page-setting.scss
vendored
@ -113,7 +113,8 @@
|
||||
.ivu-form {
|
||||
overflow: auto;
|
||||
}
|
||||
.setting-color {
|
||||
.setting-color,
|
||||
.setting-template {
|
||||
min-width: 400px;
|
||||
max-width: 600px;
|
||||
margin-bottom: 12px;
|
||||
@ -128,7 +129,6 @@
|
||||
width: 60px;
|
||||
flex: auto;
|
||||
flex-shrink: 0;
|
||||
max-width: 60px;
|
||||
}
|
||||
.ivu-color-picker {
|
||||
width: 100%;
|
||||
@ -138,6 +138,17 @@
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
.setting-template {
|
||||
> div {
|
||||
flex-shrink: 0;
|
||||
text-align: left;
|
||||
&:last-child {
|
||||
flex: 1;
|
||||
width: auto;
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
.setting-footer {
|
||||
> button {
|
||||
height: 34px;
|
||||
@ -166,6 +177,36 @@
|
||||
padding: 24px 40px;
|
||||
overflow: auto;
|
||||
}
|
||||
.ivu-tabs {
|
||||
flex: 1;
|
||||
padding: 16px 32px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.ivu-tabs-content {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
.ivu-tabs-tabpane {
|
||||
position: relative;
|
||||
.preference-task-priority,
|
||||
.preference-project-create {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.ivu-form {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
.setting-footer {
|
||||
margin: 0 -32px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.setting-footer {
|
||||
flex-shrink: 0;
|
||||
position: static;
|
||||
|
Loading…
x
Reference in New Issue
Block a user