Skip to content

Commit

Permalink
fix status
Browse files Browse the repository at this point in the history
  • Loading branch information
itimor committed Feb 6, 2021
1 parent c457ab8 commit edc360f
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 11 deletions.
4 changes: 2 additions & 2 deletions backend/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
'DEFAULT_PAGINATION_CLASS': 'common.pagination.StandardResultsSetPagination',
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.AllowAny',
'rest_framework.permissions.IsAuthenticated',
'systems.permissions.IsOwnerRoles',
# 'rest_framework.permissions.IsAuthenticated',
# 'systems.permissions.IsOwnerRoles',
),
'DEFAULT_FILTER_BACKENDS': (
'django_filters.rest_framework.DjangoFilterBackend',
Expand Down
27 changes: 27 additions & 0 deletions backend/workflows/migrations/0002_auto_20210206_1443.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.0.3 on 2021-02-06 06:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('workflows', '0001_initial'),
]

operations = [
migrations.AlterModelOptions(
name='workflowtype',
options={'ordering': ['order_id'], 'verbose_name': '工作流类型', 'verbose_name_plural': '工作流类型'},
),
migrations.AddField(
model_name='workflowtype',
name='status',
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='customfield',
name='field_type',
field=models.CharField(choices=[(1, '字符串'), (2, '整型'), (3, '浮点型'), (4, '布尔'), (5, '日期'), (6, '日期时间'), (7, '范围日期'), (8, '文本域'), (9, '单选框'), (10, '下拉列表'), (11, '用户名'), (12, '多选框'), (13, '多选下拉'), (14, '多选用户名')], default=0, max_length=1, verbose_name='字段类型'),
),
]
1 change: 1 addition & 0 deletions backend/workflows/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class WorkflowType(BaseModel):
name = models.CharField('名称', max_length=50)
status = models.BooleanField(default=True)
code = models.CharField(max_length=32, unique=True, verbose_name='代码')
order_id = models.IntegerField('状态顺序', default=1)

Expand Down
7 changes: 6 additions & 1 deletion backend/workflows/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ def create(self, validated_data):


class WorkflowTypeSerializer(serializers.ModelSerializer):
workflow_set = WorkflowSerializer(many=True, read_only=True)
workflow_list = serializers.SerializerMethodField()
# workflow_set = WorkflowSerializer(many=True, read_only=True,)

def get_workflow_list(self, instance):
a = instance.workflow_set.get_queryset().filter(status=True)
return a.values()

class Meta:
model = WorkflowType
Expand Down
2 changes: 1 addition & 1 deletion backend/workflows/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class WorkflowTypeViewSet(BulkModelMixin):
queryset = WorkflowType.objects.all()
serializer_class = WorkflowTypeSerializer
search_fields = ['name']
filter_fields = ['name', 'code']
filter_fields = ['name', 'code', 'status']


class WorkflowViewSet(BulkModelMixin):
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/views/ticket/new_ticket.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
<template>
<div class="app-container">
<el-card class="box-card" v-for="(item, key) in list" :key="item.id">
<el-card class="box-card" v-if="item.workflow_list.length>0" v-for="(item, key) in list" :key="item.id">
<div slot="header">
<span class="card-title">{{item.name}}</span>
</div>
<el-row :gutter="20">
<el-col :span="4" v-for="w in item.workflow_set" :key="w.id">
<div v-if="w.status" style="height:50px;">
<el-col :span="4" v-for="w in item.workflow_list" :key="w.id">
<div style="height:50px;">
<router-link v-if="key < 4" :class="'pan-btn ' + wf_color[key]" :to="'/u_ticket/' + w.id">{{w.name}}</router-link>
<router-link v-else :class="'pan-btn ' + wf_color[999]" :to="'/u_ticket/' + w.id">{{w.name}}</router-link>
</div>
<div v-else style="height:50px;">
<a :class="'pan-btn ' + wf_color[999]" style="color:red; font-size: 1.1rem;">无可用工单</a>
</div>
</el-col>
</el-row>
</el-card>
Expand Down Expand Up @@ -47,6 +44,9 @@ export default {
2: "green-btn",
3: "yellow-btn",
999: "tiffany-btn"
},
listQuery: {
status: true
}
};
},
Expand All @@ -73,7 +73,7 @@ export default {
});
},
getList() {
workflowtype.requestGet().then(response => {
workflowtype.requestGet(this.listQuery).then(response => {
this.list = response.results;
});
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/views/workflow/wfset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ export default {
type: "success",
duration: 2000
});
this.getList();
})
.catch(() => {
this.loading = false;
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/views/workflow/wftype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
>
<el-table-column label="名称" prop="name"></el-table-column>
<el-table-column label="code" prop="code"></el-table-column>
<el-table-column label="状态" prop="status" sortable="custom">
<template slot-scope="{ row }">
<el-tag v-if="row.status" type="success">启用</el-tag>
<el-tag v-else type="danger">禁用</el-tag>
</template>
</el-table-column>
<el-table-column label="顺序" prop="order_id"></el-table-column>
<el-table-column label="操作" align="center" width="260" class-name="small-padding fixed-width">
<template slot-scope="{ row }">
Expand Down Expand Up @@ -86,6 +92,9 @@
<el-form-item label="code" prop="code">
<el-input v-model="temp.code" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-switch v-model="temp.status" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
</el-form-item>
<el-form-item label="顺序" prop="order_id">
<el-input v-model="temp.order_id" />
</el-form-item>
Expand Down Expand Up @@ -196,6 +205,7 @@ export default {
this.temp = {
name: "",
code: "",
status: true,
order_id: "",
memo: ""
};
Expand Down Expand Up @@ -253,6 +263,7 @@ export default {
type: "success",
duration: 2000
});
this.getList();
})
.catch(() => {
this.loading = false;
Expand Down

0 comments on commit edc360f

Please sign in to comment.