add.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view class="main">
  3. <view class="form">
  4. <view class="form_group">
  5. <view class="lable">所属科室</view>
  6. <input :value="user.dept.deptName || '无科室'" disabled />
  7. </view>
  8. <view class="form_group" v-if="item.type == 0">
  9. <view class="lable">提醒标题</view>
  10. <input v-model="item.templateName" placeholder="请输入提醒标题" />
  11. </view>
  12. <view class="form_group" v-if="item.type == 1">
  13. <view class="lable">随访模板</view>
  14. <picker :range="templateList" range-key="title" @change="picker">
  15. <input placeholder="请选择" v-model="item.templateName" :disabled="true" />
  16. <view class="icon more">&#xe62b;</view>
  17. </picker>
  18. </view>
  19. <view class="form_group">
  20. <view class="lable">指定患者</view>
  21. <picker @click="go()" disabled v-if="item.patientList">
  22. <input placeholder="请选择" :value="item.patientList.length > 0 ? '已选择:' + item.patientList.length + '人' : ''" :disabled="true" />
  23. <view class="icon more">&#xe62b;</view>
  24. </picker>
  25. <input :value="item.patientName" v-else />
  26. </view>
  27. <view class="form_group" v-if="item.type == 0">
  28. <view class="lable">提醒内容</view>
  29. <textarea v-model="item.op" placeholder="请输入提醒内容"></textarea>
  30. </view>
  31. </view>
  32. <button class="btn" @click="add()">确认</button>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. user: this.getUser(),
  40. item: { patientList: [], op: '根据您于本院做的体检结果异常,请到岑溪人民医院做复诊' },
  41. templateList: []
  42. };
  43. },
  44. onLoad(e) {
  45. this.item.type = e.type || 0;
  46. this.getTemplateList();
  47. this.getDeatil(e);
  48. uni.$on('selectUser', (res) => {
  49. this.item.patientList = res;
  50. });
  51. },
  52. methods: {
  53. getDeatil(e) {
  54. if (e.id) {
  55. this.http.request({
  56. url: '/work/record/detail/' + e.id,
  57. success: (res) => {
  58. this.item = res.data.data;
  59. this.item.patientName = e.patientName;
  60. uni.setNavigationBarTitle({ title: '编辑' });
  61. }
  62. });
  63. }
  64. },
  65. picker(e, tag) {
  66. this.item.templateName = this.templateList[e.detail.value].title;
  67. this.item.op = this.templateList[e.detail.value].op;
  68. this.$forceUpdate();
  69. },
  70. //随访模板
  71. getTemplateList() {
  72. this.http.request({
  73. url: '/work/record/template/list',
  74. success: (res) => {
  75. this.templateList = res.data.data;
  76. }
  77. });
  78. },
  79. //指定患者
  80. go() {
  81. uni.navigateTo({ url: '/pages/follow/doctor/selectUser?selected=' + JSON.stringify(this.item.patientList) });
  82. },
  83. add() {
  84. let rule = [{ name: 'templateName', checkType: 'notnull', errorMsg: this.item.type == 0 ? '提醒标题' : '请选择随访模板' }];
  85. if (!this.verify.check(this.item, rule)) {
  86. uni.showModal({ content: this.verify.error, showCancel: false });
  87. return false;
  88. }
  89. this.http.request({
  90. url: this.item.id ? '/work/record/edit' : '/work/record/add',
  91. method: 'POST',
  92. data: this.item,
  93. success: (res) => {
  94. uni.showModal({
  95. title: '提示',
  96. content: '操作成功',
  97. showCancel: false,
  98. success: (res) => {
  99. uni.$emit('record');
  100. uni.navigateBack();
  101. }
  102. });
  103. }
  104. });
  105. }
  106. }
  107. };
  108. </script>
  109. <style lang="scss"></style>