Files
xk-doctor-wx/subPackages/sub_workbench/prescription_v2/components/ChineseMedicineConfig.vue

386 lines
11 KiB
Vue
Raw Normal View History

2026-03-06 13:59:22 +08:00
<template>
<view class="chinese-medicine-config">
<!-- 制剂方式 -->
<view class="config-section m-b-32">
<view class="section-title m-b-16">
<d-text text="制剂方式" className="fs-30 font-bold color-title"></d-text>
2026-03-06 13:59:22 +08:00
</view>
<view class="section-content">
<view class="modern-pill-group">
<view
class="modern-pill"
2026-07-03 16:49:12 +08:00
:class="{ active: localConfig.ruleType === 1, disabled: disabled }"
@click="!disabled && handleRuleTypeChange(1)"
2026-03-06 13:59:22 +08:00
>
自制剂
</view>
<view
class="modern-pill"
2026-07-03 16:49:12 +08:00
:class="{ active: localConfig.ruleType === 2, disabled: disabled }"
@click="!disabled && handleRuleTypeChange(2)"
2026-03-06 13:59:22 +08:00
>
委托调剂
</view>
</view>
</view>
</view>
2026-03-06 13:59:22 +08:00
<!-- 自制剂配置 -->
<view class="config-section border-t-dashed pt-32 m-b-32" v-if="localConfig.ruleType === 1">
<view class="section-title m-b-16">
<d-text text="包法选择" className="fs-30 font-bold color-title"></d-text>
2026-03-06 13:59:22 +08:00
</view>
<view class="section-content">
<view class="modern-pill-group">
<view
v-for="item in packageMethodList"
:key="item.id"
class="modern-pill outline"
2026-07-03 16:49:12 +08:00
:class="{ active: localConfig.packageMethodId === item.id, disabled: disabled }"
@click="!disabled && handlePackageMethodTagClick(item)"
2026-03-06 13:59:22 +08:00
>
{{ item.name }}
</view>
</view>
</view>
</view>
2026-03-06 13:59:22 +08:00
<!-- 委托调剂配置 -->
<view class="config-section border-t-dashed pt-32" v-if="localConfig.ruleType === 2">
<view class="section-title m-b-16">
<d-text text="制剂要求" className="fs-30 font-bold color-title"></d-text>
2026-03-06 13:59:22 +08:00
</view>
<view class="section-content m-b-24">
<view class="modern-pill-group">
<view
v-for="item in processRuleList"
:key="item.id"
class="modern-pill outline"
2026-07-03 16:49:12 +08:00
:class="{ active: localConfig.processRuleId === item.id, disabled: disabled }"
@click="!disabled && handleProcessRuleTagClick(item)"
2026-03-06 13:59:22 +08:00
>
{{ item.name }}
</view>
</view>
</view>
<view class="section-title m-b-16 m-t-24">
<d-text text="煎法说明" className="fs-30 font-bold color-title"></d-text>
2026-03-06 13:59:22 +08:00
</view>
<view class="section-content m-b-24">
<view class="modern-pill-group">
<view
v-for="item in childProcessRuleList"
:key="item.id"
class="modern-pill outline"
2026-07-03 16:49:12 +08:00
:class="{ active: localConfig.childProcessRuleId === item.id, disabled: disabled }"
@click="!disabled && handleChildProcessRuleTagClick(item)"
2026-03-06 13:59:22 +08:00
>
{{ item.name }}
</view>
</view>
</view>
<view class="section-title m-b-16 m-t-24">
<d-text text="附加备注" className="fs-30 font-bold color-title"></d-text>
2026-03-06 13:59:22 +08:00
</view>
<view class="section-content m-b-32">
<view class="modern-pill-group">
<view
v-for="item in processRuleNoteList"
:key="item.id"
class="modern-pill outline"
2026-07-03 16:49:12 +08:00
:class="{ active: localConfig.processRuleNoteId === item.id, disabled: disabled }"
@click="!disabled && handleProcessRuleNoteTagClick(item)"
2026-03-06 13:59:22 +08:00
>
{{ item.note || item.name }}
</view>
</view>
</view>
</view>
<!-- 用量和频次 WesternUsageModal 保持一致的表单布局 -->
<view class="config-form border-t-dashed pt-20">
<view class="form-item flex-row flex-jus-sp flex-ali-center p-y-24">
<view class="item-label">
<d-text text="剂数" className="fs-30 font-bold color-title"></d-text>
</view>
<view class="item-content flex-row flex-ali-center">
<u-number-box
v-model="localConfig.dosage"
2026-07-03 16:49:12 +08:00
:disabled="disabled"
:min="1"
:input-width="80"
:input-height="60"
bg-color="#F7F8FA"
/>
<d-text text="剂(天)" className="fs-28 color-sub m-l-16"></d-text>
</view>
2026-03-06 13:59:22 +08:00
</view>
<view class="form-item flex-row flex-jus-sp flex-ali-center p-y-24">
<view class="item-label">
<d-text text="用药频次" className="fs-30 font-bold color-title"></d-text>
</view>
<view class="item-content flex-row flex-ali-center">
<u-number-box
v-model="localConfig.dayDosage"
2026-07-03 16:49:12 +08:00
:disabled="disabled"
:min="1"
:input-width="80"
:input-height="60"
bg-color="#F7F8FA"
/>
<d-text text="次/天" className="fs-28 color-sub m-l-16"></d-text>
</view>
2026-03-06 13:59:22 +08:00
</view>
</view>
</view>
</template>
<script>
// 保留原有逻辑
2026-03-06 13:59:22 +08:00
export default {
name: 'ChineseMedicineConfig',
props: {
/**
* 中药配置
*/
config: {
type: Object,
default: () => ({
ruleType: 1,
packageMethodId: null,
processRuleId: null,
childProcessRuleId: null,
processRuleNoteId: null,
dosage: 7,
dayDosage: 2
})
},
/**
* 制剂列表
*/
processRuleList: {
type: Array,
default: () => []
},
/**
* 煎法列表
*/
childProcessRuleList: {
type: Array,
default: () => []
},
/**
* 备注列表
*/
processRuleNoteList: {
type: Array,
default: () => []
2026-07-03 16:49:12 +08:00
},
/**
* 特色方锁定后禁止修改配置
*/
disabled: {
type: Boolean,
default: false
2026-03-06 13:59:22 +08:00
}
},
data() {
return {
localConfig: {},
packageMethodList: [
{ id: 1, name: '味包' },
{ id: 2, name: '剂包' }
]
};
},
watch: {
config: {
handler(newVal) {
this.localConfig = { ...newVal };
},
immediate: true,
deep: true
},
localConfig: {
handler(newVal) {
this.$emit('update:config', { ...newVal });
},
deep: true
}
},
methods: {
/**
* 处理制剂方式改变
* @param {number} value - 制剂方式1=自制剂2=委托调剂
* 职责更新制剂方式触发配置更新
*/
handleRuleTypeChange(value) {
this.localConfig.ruleType = value;
// 切换时清空相关配置
if (value === 1) {
// 自制剂:清空委托调剂相关配置,默认选择第一个包法
this.localConfig.processRuleId = null;
this.localConfig.childProcessRuleId = null;
this.localConfig.processRuleNoteId = null;
// 如果包法未选择,默认选择第一个
if (!this.localConfig.packageMethodId && this.packageMethodList.length > 0) {
this.localConfig.packageMethodId = this.packageMethodList[0].id;
}
} else {
// 委托调剂:清空自制剂相关配置
this.localConfig.packageMethodId = null;
}
},
2026-03-06 13:59:22 +08:00
/**
* 处理包法改变标签点击
* @param {Object} item - 包法项
* 职责更新包法ID
*/
handlePackageMethodTagClick(item) {
this.localConfig.packageMethodId = item.id;
},
2026-03-06 13:59:22 +08:00
/**
* 处理制剂改变标签点击
* @param {Object} item - 制剂项
* 职责更新制剂ID触发加载煎法列表
*/
handleProcessRuleTagClick(item) {
// 清空煎法和备注ID级联清空
this.localConfig.processRuleId = item.id;
this.localConfig.childProcessRuleId = null;
this.localConfig.processRuleNoteId = null;
// localConfig 的变化会通过 watch 自动触发 @update:config
},
2026-03-06 13:59:22 +08:00
/**
* 处理煎法改变标签点击
* @param {Object} item - 煎法项
* 职责更新煎法ID触发加载备注列表
*/
handleChildProcessRuleTagClick(item) {
// 清空备注ID级联清空
this.localConfig.childProcessRuleId = item.id;
this.localConfig.processRuleNoteId = null;
// localConfig 的变化会通过 watch 自动触发 @update:config
},
2026-03-06 13:59:22 +08:00
/**
* 处理备注改变标签点击
* @param {Object} item - 备注项
* 职责更新备注ID
*/
handleProcessRuleNoteTagClick(item) {
this.localConfig.processRuleNoteId = item.id;
},
2026-03-06 13:59:22 +08:00
/**
* 获取包法名称
* @returns {string} 包法名称
*/
getPackageMethodName() {
const item = this.packageMethodList.find(item => item.id === this.localConfig.packageMethodId);
return item?.name || '';
},
2026-03-06 13:59:22 +08:00
/**
* 获取制剂名称
* @returns {string} 制剂名称
*/
getProcessRuleName() {
const item = this.processRuleList.find(item => item.id === this.localConfig.processRuleId);
return item?.name || '';
},
2026-03-06 13:59:22 +08:00
/**
* 获取煎法名称
* @returns {string} 煎法名称
*/
getChildProcessRuleName() {
const item = this.childProcessRuleList.find(item => item.id === this.localConfig.childProcessRuleId);
return item?.name || '';
},
2026-03-06 13:59:22 +08:00
/**
* 获取备注名称
* @returns {string} 备注名称
*/
getProcessRuleNoteName() {
const item = this.processRuleNoteList.find(item => item.id === this.localConfig.processRuleNoteId);
return item?.name || '';
}
}
};
</script>
<style lang="scss" scoped>
/* 统一样式 */
.color-title { color: #2A2E35; }
.color-sub { color: #8A92A3; }
.fs-28 { font-size: 28rpx; }
.fs-30 { font-size: 30rpx; }
.font-bold { font-weight: bold; }
.m-b-16 { margin-bottom: 16rpx; }
.m-b-24 { margin-bottom: 24rpx; }
.m-b-32 { margin-bottom: 32rpx; }
.m-t-24 { margin-top: 24rpx; }
.m-l-16 { margin-left: 16rpx; }
.pt-20 { padding-top: 20rpx; }
.pt-32 { padding-top: 32rpx; }
.p-y-24 { padding: 24rpx 0; }
.border-t-dashed { border-top: 1px dashed #E2E8F0; }
2026-03-06 13:59:22 +08:00
.flex-row { display: flex; flex-direction: row; }
.flex-jus-sp { justify-content: space-between; }
.flex-ali-center { align-items: center; }
2026-03-06 13:59:22 +08:00
.chinese-medicine-config {
2026-03-06 13:59:22 +08:00
display: flex;
flex-direction: column;
2026-03-06 13:59:22 +08:00
}
.modern-pill-group {
2026-03-06 13:59:22 +08:00
display: flex;
gap: 16rpx;
flex-wrap: wrap;
}
.modern-pill {
padding: 12rpx 36rpx;
background-color: #F4F6F8;
color: #6C7380;
border-radius: 40rpx;
font-size: 26rpx;
2026-03-06 13:59:22 +08:00
text-align: center;
cursor: pointer;
border: 1px solid transparent;
transition: all 0.2s;
2026-03-06 13:59:22 +08:00
&.active {
background-color: #00A88A;
color: #fff;
border-color: #00A88A;
font-weight: bold;
}
2026-03-06 13:59:22 +08:00
&.outline {
background-color: #fff;
border: 1px solid #E2E8F0;
2026-03-06 13:59:22 +08:00
&.active {
background-color: #E8F6F4;
color: #00A88A;
border-color: #00A88A;
}
}
2026-07-03 16:49:12 +08:00
&.disabled {
opacity: 0.5;
pointer-events: none;
}
2026-03-06 13:59:22 +08:00
}
</style>