PurchaseDetailsForm.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 placeholder="请输入物料编号" v-model="model.materialNo"/>
  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.materialName"/>
  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.unit"/>
  27. </view>
  28. </view>
  29. <view class="cu-form-group">
  30. <view class="flex align-center">
  31. <view class="title"><text space="ensp">品牌:</text></view>
  32. <input placeholder="请输入品牌" v-model="model.brand"/>
  33. </view>
  34. </view>
  35. <view class="cu-form-group">
  36. <view class="flex align-center">
  37. <view class="title"><text space="ensp">规格型号:</text></view>
  38. <input placeholder="请输入规格型号" v-model="model.specification"/>
  39. </view>
  40. </view>
  41. <view class="cu-form-group">
  42. <view class="flex align-center">
  43. <view class="title"><text space="ensp">供应商:</text></view>
  44. <input placeholder="请输入供应商" v-model="model.supplier"/>
  45. </view>
  46. </view>
  47. <my-date label="申请时间:" v-model="model.applicationTime" placeholder="请输入申请时间"></my-date>
  48. <my-date label="期望供货时间:" fields="day" v-model="model.expectedDeliveryTime" placeholder="请输入期望供货时间"></my-date>
  49. <view class="cu-form-group">
  50. <view class="flex align-center">
  51. <view class="title"><text space="ensp">申请人:</text></view>
  52. <input placeholder="请输入申请人" v-model="model.applicant"/>
  53. </view>
  54. </view>
  55. <view class="cu-form-group">
  56. <view class="flex align-center">
  57. <view class="title"><text space="ensp">申请数量:</text></view>
  58. <input type="number" placeholder="请输入申请数量" v-model="model.quantity"/>
  59. </view>
  60. </view>
  61. <view class="cu-form-group">
  62. <view class="flex align-center">
  63. <view class="title"><text space="ensp">预计单价:</text></view>
  64. <input type="number" placeholder="请输入预计单价" v-model="model.expectedPrice"/>
  65. </view>
  66. </view>
  67. <view class="cu-form-group">
  68. <view class="flex align-center">
  69. <view class="title"><text space="ensp">实际单价:</text></view>
  70. <input type="number" placeholder="请输入实际单价" v-model="model.actualPrice"/>
  71. </view>
  72. </view>
  73. <view class="cu-form-group">
  74. <view class="flex align-center">
  75. <view class="title"><text space="ensp">到货量:</text></view>
  76. <input type="number" placeholder="请输入到货量" v-model="model.arrivalQuantity"/>
  77. </view>
  78. </view>
  79. <view class="cu-form-group">
  80. <view class="flex align-center">
  81. <view class="title"><text space="ensp">备注:</text></view>
  82. <input placeholder="请输入备注" v-model="model.remark"/>
  83. </view>
  84. </view>
  85. <view class="cu-form-group">
  86. <view class="flex align-center">
  87. <view class="title"><text space="ensp">申请单号:</text></view>
  88. <input placeholder="请输入申请单号" v-model="model.requestNo"/>
  89. </view>
  90. </view>
  91. <view class="padding">
  92. <button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
  93. <text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
  94. </button>
  95. </view>
  96. </form>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. import myDate from '@/components/my-componets/my-date.vue'
  102. export default {
  103. name: "PurchaseDetailsForm",
  104. components:{ myDate },
  105. props:{
  106. formData:{
  107. type:Object,
  108. default:()=>{},
  109. required:false
  110. }
  111. },
  112. data(){
  113. return {
  114. CustomBar: this.CustomBar,
  115. NavBarColor: this.NavBarColor,
  116. loading:false,
  117. model: {},
  118. backRouteName:'index',
  119. url: {
  120. queryById: "/purchaseManage/purchaseDetails/queryById",
  121. add: "/purchaseManage/purchaseDetails/add",
  122. edit: "/purchaseManage/purchaseDetails/edit",
  123. },
  124. }
  125. },
  126. created(){
  127. this.initFormData();
  128. },
  129. methods:{
  130. initFormData(){
  131. if(this.formData){
  132. let dataId = this.formData.dataId;
  133. this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
  134. if(res.data.success){
  135. console.log("表单数据",res);
  136. this.model = res.data.result;
  137. }
  138. })
  139. }
  140. },
  141. onSubmit() {
  142. let myForm = {...this.model};
  143. this.loading = true;
  144. let url = myForm.id?this.url.edit:this.url.add;
  145. this.$http.post(url,myForm).then(res=>{
  146. console.log("res",res)
  147. this.loading = false
  148. this.$Router.push({name:this.backRouteName})
  149. }).catch(()=>{
  150. this.loading = false
  151. });
  152. }
  153. }
  154. }
  155. </script>