Skip to content

Commit

Permalink
副表干员编辑
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed Nov 9, 2023
1 parent ef5b115 commit 7d83090
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 40 deletions.
2 changes: 1 addition & 1 deletion ui/src/components/PlanEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import pinyinMatch from 'pinyin-match/es/traditional'
import { NAvatar, NTag } from 'naive-ui'
const config_store = useConfigStore()
const plan_store = usePlanStore()
const { operators, plan, groups } = storeToRefs(plan_store)
const { operators, groups, current_plan: plan } = storeToRefs(plan_store)
const { facility_operator_limit } = plan_store
const { theme } = storeToRefs(config_store)
Expand Down
87 changes: 84 additions & 3 deletions ui/src/pages/Plan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const {
operators,
workaholic,
backup_plans,
plan
plan,
sub_plan
} = storeToRefs(plan_store)
const { load_plan } = plan_store
Expand Down Expand Up @@ -66,8 +67,6 @@ async function save() {
const mobile = inject('mobile')
const sub_plan = ref('main')
const sub_plan_options = computed(() => {
const result = [
{
Expand Down Expand Up @@ -110,6 +109,13 @@ function delete_sub_plan() {
backup_plans.value.splice(sub_plan.value, 1)
sub_plan.value = 'main'
}
const current_conf = computed(() => {
if (sub_plan.value == 'main') {
return {}
}
return backup_plans.value[sub_plan.value].conf
})
</script>
<template>
Expand All @@ -133,6 +139,7 @@ function delete_sub_plan() {
:show-feedback="false"
label-width="160"
label-align="left"
v-if="sub_plan == 'main'"
>
<n-form-item>
<template #label>
Expand Down Expand Up @@ -185,6 +192,80 @@ function delete_sub_plan() {
<n-select multiple filterable tag :options="operators" v-model:value="resting_priority" />
</n-form-item>
</n-form>
<n-form
class="w-980 mx-auto mb-12"
:label-placement="mobile ? 'top' : 'left'"
:show-feedback="false"
label-width="160"
label-align="left"
v-else
>
<n-form-item>
<template #label>
<span>令夕模式</span>
<help-text>
<div>令夕上班时起作用</div>
<div>启动Mower前需要手动对齐心情</div>
<div>感知:夕心情-令心情=12</div>
<div>烟火:令心情-夕心情=12</div>
<div>均衡:夕令心情一样</div>
</help-text>
</template>
<n-radio-group v-model:value="current_conf.ling_xi">
<n-space>
<n-radio :value="1">感知信息</n-radio>
<n-radio :value="2">人间烟火</n-radio>
<n-radio :value="3">均衡模式</n-radio>
</n-space>
</n-radio-group>
</n-form-item>
<n-form-item>
<template #label>
<span>最大组人数</span><help-text><div>请查阅文档</div></help-text>
</template>
<n-input-number v-model:value="current_conf.max_resting_count" />
</n-form-item>
<n-form-item>
<template #label>
<span>需要回满心情的干员</span><help-text><div>请查阅文档</div></help-text>
</template>
<n-select multiple filterable tag :options="operators" v-model:value="current_conf.rest_in_full" />
</n-form-item>
<n-form-item>
<template #label>
<span>需要用尽心情的干员</span
><help-text><div>仅推荐写入具有暖机技能的干员</div></help-text>
</template>
<n-select multiple filterable tag :options="operators" v-model:value="current_conf.exhaust_require" />
</n-form-item>
<n-form-item>
<template #label>
<span>0心情工作的干员</span><help-text><div>心情涣散状态任能触发技能的干员</div></help-text>
</template>
<n-select multiple filterable tag :options="operators" v-model:value="current_conf.workaholic" />
</n-form-item>
<n-form-item>
<template #label>
<span>宿舍低优先级干员</span><help-text><div>请查阅文档</div></help-text>
</template>
<n-select multiple filterable tag :options="operators" v-model:value="current_conf.resting_priority" />
</n-form-item>
<n-form-item v-if="sub_plan != 'main'">
<template #label>
<span>宿舍黑名单</span>
<help-text>
<div>不希望进行填充宿舍的干员</div>
</help-text>
</template>
<n-select
multiple
filterable
tag
:options="operators"
v-model:value="current_conf.free_blacklist"
/>
</n-form-item>
</n-form>
</template>
<style scoped lang="scss">
Expand Down
131 changes: 95 additions & 36 deletions ui/src/stores/plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ export const usePlanStore = defineStore('plan', () => {
facility_operator_limit[`dormitory_${i}`] = 5
}

async function load_plan() {
const response = await axios.get(`${import.meta.env.VITE_HTTP_URL}/plan`)
ling_xi.value = response.data.conf.ling_xi
max_resting_count.value = response.data.conf.max_resting_count
exhaust_require.value =
response.data.conf.exhaust_require == '' ? [] : response.data.conf.exhaust_require.split(',')
rest_in_full.value =
response.data.conf.rest_in_full == '' ? [] : response.data.conf.rest_in_full.split(',')
resting_priority.value =
response.data.conf.resting_priority == ''
? []
: response.data.conf.resting_priority.split(',')
workaholic.value =
response.data.conf.workaholic == '' ? [] : response.data.conf.workaholic.split(',')
backup_plans.value = response.data.backup_plans ?? []
function list2str(data) {
return data.join(',')
}

function str2list(data) {
return data.split(',')
}

const full_plan = response.data.plan1
const backup_conf_convert_list = [
'exhaust_require',
'rest_in_full',
'resting_priority',
'workaholic',
'free_blacklist'
]

function fill_empty(full_plan) {
for (const i in facility_operator_limit) {
let count = 0
if (!full_plan[i]) {
Expand All @@ -66,19 +66,7 @@ export const usePlanStore = defineStore('plan', () => {
full_plan[i].plans.push({ agent: '', group: '', replacement: [] })
}
}
plan.value = full_plan
}

async function load_operators() {
const response = await axios.get(`${import.meta.env.VITE_HTTP_URL}/operator`)
const option_list = []
for (const i of response.data) {
option_list.push({
value: i,
label: i
})
}
operators.value = option_list
return full_plan
}

function remove_empty_agent(input) {
Expand All @@ -94,19 +82,79 @@ export const usePlanStore = defineStore('plan', () => {
return result
}

function strip_plan(plan) {
const plan1 = {}

for (const i in facility_operator_limit) {
if (i.startsWith('room') && plan[i].name) {
plan1[i] = remove_empty_agent(plan[i])
} else {
let empty = true
for (const j of plan[i].plans) {
if (j.agent) {
empty = false
break
}
}
if (!empty) {
plan1[i] = remove_empty_agent(plan[i])
}
}
}

return plan1
}

async function load_plan() {
const response = await axios.get(`${import.meta.env.VITE_HTTP_URL}/plan`)
ling_xi.value = response.data.conf.ling_xi
max_resting_count.value = response.data.conf.max_resting_count
exhaust_require.value = str2list(response.data.conf.exhaust_require)
rest_in_full.value = str2list(response.data.conf.rest_in_full)
resting_priority.value = str2list(response.data.conf.resting_priority)
workaholic.value = str2list(response.data.conf.workaholic)
plan.value = fill_empty(response.data.plan1)

backup_plans.value = response.data.backup_plans ?? []
for (let b of backup_plans.value) {
for (const i of backup_conf_convert_list) {
b.conf[i] = str2list(b.conf[i])
}
b.plan = fill_empty(b.plan)
}
}

async function load_operators() {
const response = await axios.get(`${import.meta.env.VITE_HTTP_URL}/operator`)
const option_list = []
for (const i of response.data) {
option_list.push({
value: i,
label: i
})
}
operators.value = option_list
}

function build_plan() {
const result = {
default: 'plan1',
plan1: {},
plan1: strip_plan(plan.value),
conf: {
ling_xi: ling_xi.value,
max_resting_count: max_resting_count.value,
exhaust_require: exhaust_require.value.join(','),
rest_in_full: rest_in_full.value.join(','),
resting_priority: resting_priority.value.join(','),
workaholic: workaholic.value.join(',')
exhaust_require: list2str(exhaust_require.value),
rest_in_full: list2str(rest_in_full.value),
resting_priority: list2str(resting_priority.value),
workaholic: list2str(workaholic.value)
},
backup_plans: backup_plans.value
backup_plans: JSON.parse(JSON.stringify(backup_plans.value))
}
for (const b of result.backup_plans) {
for (const i of backup_conf_convert_list) {
b.conf[i] = list2str(b.conf[i])
}
b.plan = strip_plan(b.plan)
}

const plan1 = result.plan1
Expand Down Expand Up @@ -160,6 +208,15 @@ export const usePlanStore = defineStore('plan', () => {
return [...new Set(result)]
})

const sub_plan = ref('main')
const current_plan = computed(() => {
if (sub_plan.value == 'main') {
return plan.value
} else {
return backup_plans.value[sub_plan.value].plan
}
})

return {
load_plan,
load_operators,
Expand All @@ -175,6 +232,8 @@ export const usePlanStore = defineStore('plan', () => {
left_side_facility,
build_plan,
groups,
backup_plans
backup_plans,
sub_plan,
current_plan
}
})

0 comments on commit 7d83090

Please sign in to comment.