123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <template>
- <view>
- <uni-section padding>
- <uni-forms ref="bhForms" :model="forms" :rules="rules">
- <uni-forms-item label="病患描述" name="bhms">
- <uni-easyinput v-model="forms.bhms" placeholder="请输入病患描述" />
- </uni-forms-item>
- <uni-forms-item label="病患类别" name="bhlb">
- <uni-data-select v-model="forms.bhlb" placeholder="请选择病患类别" :localdata="dicts.KH004" />
- </uni-forms-item>
- <uni-forms-item label="患病时间" name="bhsj">
- <uni-easyinput v-model="forms.bhsj" placeholder="请输入患病时间段" />
- </uni-forms-item>
- <uni-forms-item label="使用药物" name="syyw">
- <uni-easyinput type="textarea" v-model="forms.syyw" placeholder="请输入使用药物" />
- </uni-forms-item>
- <uni-forms-item label="处置手段">
- <uni-easyinput type="textarea" v-model="forms.czsd" placeholder="请输入处置手段" />
- </uni-forms-item>
- <uni-forms-item label="愈后情况">
- <uni-easyinput type="textarea" v-model="forms.yhqk" placeholder="请输入愈后情况" />
- </uni-forms-item>
- <uni-forms-item label="康复措施">
- <uni-easyinput type="textarea" v-model="forms.kfcs" placeholder="请输入康复措施" />
- </uni-forms-item>
- <view class="bottomButton">
- <button type="primary" size="mini" @click="submitForm">保存</button>
- </view>
- </uni-forms>
- </uni-section>
- </view>
- </template>
- <script>
- import { addKhbhls, updateKhbhls } from '@/api/lr.js'
- export default {
- data() {
- return {
- dicts: {
- KH004: [],
- },
- khId: null,
- forms: {
- bhms: null,
- bhlb: null,
- bhsj: null,
- syyw: null,
- czsd: null,
- yhqk: null,
- kfcs: null,
- },
- rules: {
- bhms: {
- rules: [{
- required: true,
- errorMessage: '病患描述不能为空'
- }]
- },
- bhlb: {
- rules: [{
- required: true,
- errorMessage: '请选择病患类别'
- }]
- },
- bhsj: {
- rules: [{
- required: true,
- errorMessage: '患病时间段不能为空'
- }]
- },
- syyw: {
- rules: [{
- required: true,
- errorMessage: '使用药物不能为空'
- }]
- },
- },
- }
- },
- created() {
- this.getDictList(Object.keys(this.dicts), this.dicts)
- },
- onLoad(option) {
- if (option.item) {
- this.forms = JSON.parse(option.item)
- uni.setNavigationBarTitle({
- title: '修改病史记录'
- });
- }
- this.khId = option.id
- this.xm = option.xm
- },
- methods: {
- submitForm() {
- this.$refs['bhForms'].validate().then(res => {
- const submitForm = {
- ...this.forms,
- khId: this.khId,
- xm: this.xm,
- };
- if (this.forms.id) {
- updateKhbhls(submitForm).then(res => {
- if (res.code !== 200) return
- // 关闭窗口后,恢复默认内容
- uni.showToast({
- title: `修改成功!`,
- duration: 2000,
- success: (res) => {
- uni.$emit('changeBhls', 'bhls')
- setTimeout(function() {
- uni.navigateBack({ delta: 1 });
- }, 1000)
- }
- })
- })
- } else {
- addKhbhls(submitForm).then(res => {
- if (res.code !== 200) return
- // 关闭窗口后,恢复默认内容
- uni.showToast({
- title: `新增成功!`,
- duration: 2000,
- success: (res) => {
- uni.$emit('changeBhls', 'bhls')
- setTimeout(function() {
- uni.navigateBack({ delta: 1 });
- }, 1000)
- }
- })
- })
- }
- }).catch(err => {
- console.log('err', err);
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .bottomButton {
- height: 140rpx;
- width: 60%;
- margin: 0 auto;
- text-align: center;
- button {
- width: 40%;
- }
- button+button {
- margin-left: 15px;
- }
- }
- </style>
|