add.vue 2.8 KB

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