123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- <template>
- <view class="main">
- <view class="one">
- <upload class='upload' :list="form.icon" name="icon" :count="1" @uplSuc="uplSuc" @uplDel="uplDel">
- </upload>
- </view>
- <view class="two">
- <view class="two_1">
- <view class="left">姓名</view>
- <view class="right">
- <input v-model="form.name" placeholder="请输入真实姓名" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1">
- <view class="left">手机号</view>
- <view class="right">
- <input v-model="form.mobile" placeholder="请输入手机号" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role!='Patient'">
- <view class="left">医院名称</view>
- <view class="right">
- <input v-model="form.hos_name" placeholder="请输入医院名称" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role!='Patient'">
- <view class="left">科室名称</view>
- <view class="right">
- <input v-model="form.dept_name" placeholder="请输入科室名称" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role!='Patient'">
- <view class="left">职务</view>
- <view class="right">
- <input v-model="form.title" placeholder="请输入职务" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role!='Patient'">
- <view class="left">职称</view>
- <view class="right">
- <input v-model="form.post" placeholder="请输入职称" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role!='Patient'">
- <view class="left">简介</view>
- <view class="right">
- <input v-model="form.content" placeholder="请输入简介" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role=='Patient'">
- <view class="left">就诊编号/卡号</view>
- <view class="right">
- <input v-model="form.card_no" placeholder="请输入就诊编号/卡号" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role=='Patient'">
- <view class="left">性别</view>
- <view class="right">
- <picker class="picker" mode="selector" :range="genderList" @change="genderChange" range-key="label">
- <view>{{form.gender||'请选择性别'}}</view>
- </picker>
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role=='Patient'">
- <view class="left">年龄</view>
- <view class="right">
- <input v-model="form.age" placeholder="请输入年龄" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role=='Patient'">
- <view class="left">住址</view>
- <view class="right">
- <input v-model="form.address" placeholder="请输入住址" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role=='Patient'">
- <view class="left">紧急联系人</view>
- <view class="right">
- <input v-model="form.urgent_name" placeholder="请输入紧急联系人" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role=='Patient'">
- <view class="left">紧急联系人电话</view>
- <view class="right">
- <input v-model="form.urgent_mobile" placeholder="请输入紧急联系人电话" />
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- <view class="two_1" v-if="user.role=='Patient'">
- <view class="left">病例</view>
- <view class="right">
- <upload class='upload' :list="form.emrs" name="emrs" :count="1" @uplSuc="uplSuc" @uplDel="uplDel">
- </upload>
- </view>
- </view>
- </view>
- <view class="thr">
- <button class="button" type="primary" size="mini" @click="onSubmit()">保存</button>
- </view>
- </view>
- </template>
- <script>
- import upload from '../../components/upload/index.vue';
- export default {
- components: {
- upload
- },
- data() {
- return {
- user: {},
- form: {},
- // 字典表
- genderList: [{
- label: '男',
- value: '男'
- },
- {
- label: '女',
- value: '女'
- }
- ],
- }
- },
- onLoad: async function(e) {
- const that = this;
- await that.searchToken();
- await that.search();
- },
- methods: {
- // 用户信息
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) {
- const user = that.$jwt(res);
- that.$set(that, `user`, user);
- }
- } catch (e) {}
- },
- // 查询
- async search() {
- const that = this;
- const user = that.user
- if (user) {
- let res;
- if (user.role == 'Doctor') res = await that.$api(`/doctor/${user._id}`, 'GET', {})
- else if (user.role == 'Nurse') res = await that.$api(`/nurse/${user._id}`, 'GET', {})
- else res = await that.$api(`/patient/${user._id}`, 'GET', {})
- if (res.errcode == '0') {
- that.$set(that, `form`, res.data)
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- });
- }
- }
- },
- // 图片上传
- uplSuc(e) {
- const that = this;
- that.$set(that.form, e.name, [e.data]);
- },
- // 图片删除
- uplDel(e) {
- const that = this;
- that.$set(that.form, e.name, [])
- },
- // 性别选择
- genderChange(e) {
- const that = this;
- let data = that.genderList[e.detail.value];
- if (data) that.$set(that.form, `gender`, data.value)
- },
- // 保存
- async onSubmit() {
- const that = this;
- const user = that.user
- const form = that.form
- if (!user) {
- uni.showToast({
- title: "缺少用户信息 无法保存!",
- icon: 'none'
- })
- return
- }
- let res;
- if (user.role == 'Doctor') res = await that.$api(`/doctor/${form._id}`, 'POST', form)
- else if (user.role == 'Nurse') res = await that.$api(`/nurse/${user._id}`, 'POST', form)
- else res = await that.$api(`/patient/${user._id}`, 'POST', form)
- if (res.errcode == '0') {
- uni.showToast({
- title: '维护信息成功',
- icon: 'none'
- })
- that.search()
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- });
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- .one {
- display: flex;
- justify-content: center;
- padding: 2vw;
- }
- .two {
- padding: 2vw;
- .two_1 {
- display: flex;
- justify-content: space-between;
- padding: 4vw;
- border-bottom: 1px solid var(--f9Color);
- font-size: var(--font14Size);
- color: var(--f69Color);
- .right {
- display: flex;
- align-items: center;
- input {
- text-align: right;
- padding: 0 1vw;
- }
- }
- }
- }
- .thr {
- text-align: center;
- .button {
- margin: 2vw 0 0 0;
- background-color: var(--f3CColor);
- color: var(--mainColor);
- font-size: var(--font14Size);
- }
- }
- }
- </style>
|