FileVisibilityForm.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view>
  3. <!--标题和返回-->
  4. <cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
  5. <block slot="backText">返回</block>
  6. <block slot="content">设备相关文件--可见范围</block>
  7. </cu-custom>
  8. <!--表单区域-->
  9. <view>
  10. <form>
  11. <view class="cu-form-group">
  12. <view class="flex align-center">
  13. <view class="title"><text space="ensp">类型:</text></view>
  14. <input type="number" placeholder="请输入类型" v-model="model.type"/>
  15. </view>
  16. </view>
  17. <view class="cu-form-group">
  18. <view class="flex align-center">
  19. <view class="title"><text space="ensp">编号:</text></view>
  20. <input placeholder="请输入编号" v-model="model.number"/>
  21. </view>
  22. </view>
  23. <view class="cu-form-group">
  24. <view class="flex align-center">
  25. <view class="title"><text space="ensp">部门/人员:</text></view>
  26. <input placeholder="请输入部门/人员" v-model="model.departmentOrStaff"/>
  27. </view>
  28. </view>
  29. <view class="cu-form-group">
  30. <view class="flex align-center">
  31. <view class="title"><text space="ensp">文件id:</text></view>
  32. <input placeholder="请输入文件id" v-model="model.fileId"/>
  33. </view>
  34. </view>
  35. <view class="padding">
  36. <button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
  37. <text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
  38. </button>
  39. </view>
  40. </form>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import myDate from '@/components/my-componets/my-date.vue'
  46. export default {
  47. name: "FileVisibilityForm",
  48. components:{ myDate },
  49. props:{
  50. formData:{
  51. type:Object,
  52. default:()=>{},
  53. required:false
  54. }
  55. },
  56. data(){
  57. return {
  58. CustomBar: this.CustomBar,
  59. NavBarColor: this.NavBarColor,
  60. loading:false,
  61. model: {},
  62. backRouteName:'index',
  63. url: {
  64. queryById: "/purchaseManage/fileVisibility/queryById",
  65. add: "/purchaseManage/fileVisibility/add",
  66. edit: "/purchaseManage/fileVisibility/edit",
  67. },
  68. }
  69. },
  70. created(){
  71. this.initFormData();
  72. },
  73. methods:{
  74. initFormData(){
  75. if(this.formData){
  76. let dataId = this.formData.dataId;
  77. this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
  78. if(res.data.success){
  79. console.log("表单数据",res);
  80. this.model = res.data.result;
  81. }
  82. })
  83. }
  84. },
  85. onSubmit() {
  86. let myForm = {...this.model};
  87. this.loading = true;
  88. let url = myForm.id?this.url.edit:this.url.add;
  89. this.$http.post(url,myForm).then(res=>{
  90. console.log("res",res)
  91. this.loading = false
  92. this.$Router.push({name:this.backRouteName})
  93. }).catch(()=>{
  94. this.loading = false
  95. });
  96. }
  97. }
  98. }
  99. </script>