Skip to content

Commit

Permalink
feat: 新增自定义添加项目时的项目模板
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Feb 9, 2022
1 parent ea58ed4 commit fb24af1
Show file tree
Hide file tree
Showing 12 changed files with 333 additions and 25 deletions.
53 changes: 52 additions & 1 deletion app/Http/Controllers/Api/SystemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,16 @@ public function demo()
}

/**
* @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错误)
Expand Down Expand Up @@ -145,6 +149,53 @@ public function priority()
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. 获取终端详细信息
*
Expand Down
3 changes: 3 additions & 0 deletions app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class VerifyCsrfToken extends Middleware
// 保存任务优先级
'api/system/priority/',

// 保存创建项目列表模板
'api/system/column/template/',

// 添加任务
'api/project/task/add/',

Expand Down
Original file line number Diff line number Diff line change
@@ -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()
{

}
}
36 changes: 21 additions & 15 deletions resources/assets/js/pages/manage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -250,6 +256,7 @@ export default {
addData: {
name: '',
columns: '',
flow: 'open',
},
addRule: {},
Expand All @@ -258,8 +265,6 @@ export default {
dialogMsgSubscribe: null,
columns: [],
projectKeyValue: '',
projectKeyAlready: {},
projectKeyLoading: 0,
Expand Down Expand Up @@ -331,6 +336,7 @@ export default {
'projectTotal',
'taskId',
'wsOpenNum',
'columnTemplate',
'themeMode',
'themeList',
Expand Down Expand Up @@ -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: '所有项目'},
Expand All @@ -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) => {
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -593,6 +598,7 @@ export default {
},
onAddShow() {
this.$store.dispatch("getColumnTemplate").catch(() => {})
this.addShow = true;
this.$nextTick(() => {
this.$refs.projectName.focus();
Expand Down Expand Up @@ -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(','));
})
},
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/pages/manage/setting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
if (this.userIsAdmin) {
menu.push(...[
{path: 'system', name: '系统设置', divided: true},
{path: 'priority', name: '任务等级'},
{path: 'preference', name: '偏好设置'},
])
}
return menu;
Expand Down
120 changes: 120 additions & 0 deletions resources/assets/js/pages/manage/setting/preference/columnTemplate.vue
Original file line number Diff line number Diff line change
@@ -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>
25 changes: 25 additions & 0 deletions resources/assets/js/pages/manage/setting/preference/index.vue
Original file line number Diff line number Diff line change
@@ -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>
Loading

0 comments on commit fb24af1

Please sign in to comment.