add.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view>
  3. <view class="forms">
  4. <view class="form_group pt0">
  5. <view class="lable re">收件人</view>
  6. <input placeholder="请输入" v-model="item.typeCode" />
  7. </view>
  8. <view class="form_group">
  9. <view class="lable re">联系电话</view>
  10. <input placeholder="请输入" v-model="item.typeCode" />
  11. </view>
  12. <view class="form_group">
  13. <view class="lable re">详细地址</view>
  14. <textarea v-model="item.remarks" placeholder="请输入"></textarea>
  15. </view>
  16. </view>
  17. <view class="mfooter">
  18. <view class="flex">
  19. <view class="f" v-if="item.id">
  20. <button class="save btn" @click="del()">删除</button>
  21. </view>
  22. <view class="f">
  23. <button class="btn" @click="save()">保存</button>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. item: {}
  34. };
  35. },
  36. onLoad(e) {
  37. if (e.id) {
  38. this.http.request({
  39. url: '/level-one-server/app/TbPortNews/getPortNewsDetails',
  40. data: { id: e.id },
  41. success: res => {
  42. this.item = res.data.data;
  43. }
  44. });
  45. }
  46. },
  47. methods: {
  48. save() {
  49. let rule = [
  50. { name: 'typeCode', checkType: 'notnull', errorMsg: '请输入编码' },
  51. { name: 'typeName', checkType: 'notnull', errorMsg: '请输入名称' },
  52. { name: 'status', checkType: 'notnull', errorMsg: '请选择状态' }
  53. ];
  54. if (!this.verify.check(this.item, rule)) {
  55. uni.showModal({ content: this.verify.error, showCancel: false });
  56. return false;
  57. }
  58. this.http.request({
  59. url: '/project/projectType',
  60. method: 'POST',
  61. data: this.item,
  62. success: res => {
  63. uni.showToast({ title: '操作成功' });
  64. setTimeout(() => {
  65. uni.$emit('address');
  66. uni.navigateBack();
  67. }, 1000);
  68. }
  69. });
  70. },
  71. del(id) {
  72. uni.showModal({
  73. title: '提示',
  74. content: '确定删除该数据?',
  75. success: res => {
  76. if (res.confirm) {
  77. this.http.request({
  78. url: '/customer/customerType',
  79. data: { id: this.item.id },
  80. method: 'POST',
  81. success: res => {
  82. uni.showToast({ title: '删除成功' });
  83. setTimeout(() => {
  84. uni.$emit('address');
  85. uni.navigateBack();
  86. }, 1000);
  87. }
  88. });
  89. }
  90. }
  91. });
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="scss"></style>