add.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="main">
  3. <view class="form">
  4. <view class="form_group">
  5. <view class="lable">所属科室</view>
  6. <input v-model="item.title" placeholder="请输入标题" />
  7. </view>
  8. <view class="form_group">
  9. <view class="lable">随访模板</view>
  10. <picker :range="templateList" range-key="title" @change="picker($event, 'type')">
  11. <input placeholder="请选择" v-model="item.type" :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 @change="picker($event, 'type')">
  18. <input placeholder="请选择" v-model="item.type" :disabled="true" />
  19. <view class="icon more">&#xe62b;</view>
  20. </picker>
  21. </view>
  22. </view>
  23. <button class="btn" @click="add()">确认</button>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. item: { state: 0 },
  31. templateList: []
  32. };
  33. },
  34. onLoad(e) {
  35. this.getTemplateList();
  36. if (e.id) {
  37. this.http.request({
  38. url: '/work/knowledge/detail/' + e.id,
  39. success: (res) => {
  40. this.item = res.data.data;
  41. this.$refs.editor.setContents();
  42. uni.setNavigationBarTitle({ title: '编辑知识库' });
  43. }
  44. });
  45. }
  46. },
  47. methods: {
  48. picker(e, tag) {
  49. if (tag == 'type') {
  50. this.item.type = this.type[e.detail.value].dictLabel;
  51. } else {
  52. this.item[tag] = e.detail.value;
  53. }
  54. this.$forceUpdate();
  55. },
  56. getTemplateList() {
  57. this.http.request({
  58. url: '/work/record/template/list',
  59. success: (res) => {
  60. this.templateList = res.data.data;
  61. }
  62. });
  63. },
  64. add() {
  65. let rule = [
  66. { name: 'title', checkType: 'notnull', errorMsg: '请输入标题' },
  67. { name: 'type', checkType: 'notnull', errorMsg: '请选择分类' },
  68. { name: 'content', checkType: 'notnull', errorMsg: '请输入内容' }
  69. ];
  70. if (!this.verify.check(this.item, rule)) {
  71. uni.showModal({ content: this.verify.error, showCancel: false });
  72. return false;
  73. }
  74. this.http.request({
  75. url: this.item.id ? '/work/knowledge/edit' : '/work/knowledge/add',
  76. method: 'POST',
  77. data: this.item,
  78. success: (res) => {
  79. uni.showModal({
  80. title: '提示',
  81. content: '操作成功',
  82. showCancel: false,
  83. success: (res) => {
  84. uni.$emit('knowledge');
  85. uni.navigateBack();
  86. }
  87. });
  88. }
  89. });
  90. }
  91. }
  92. };
  93. </script>
  94. <style lang="scss"></style>