CostModelClPriceForm.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  5. <a-row>
  6. <a-col :span="24">
  7. <a-form-model-item label="物料编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wlbm">
  8. <a-input v-model="model.wlbm" placeholder="请输入物料编码" ></a-input>
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="规格型号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ggxh">
  13. <a-input v-model="model.ggxh" placeholder="请输入规格型号" ></a-input>
  14. </a-form-model-item>
  15. </a-col>
  16. <a-col :span="24">
  17. <a-form-model-item label="质量等级" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zlLevel">
  18. <a-input v-model="model.zlLevel" placeholder="请输入质量等级" ></a-input>
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :span="24">
  22. <a-form-model-item label="批次" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="pici">
  23. <a-input v-model="model.pici" placeholder="请输入批次" ></a-input>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :span="24">
  27. <a-form-model-item label="采购时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="caigouTime">
  28. <a-input v-model="model.caigouTime" placeholder="请输入采购时间" ></a-input>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :span="24">
  32. <a-form-model-item label="单价" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="danjia">
  33. <a-input v-model="model.danjia" placeholder="请输入单价" ></a-input>
  34. </a-form-model-item>
  35. </a-col>
  36. </a-row>
  37. </a-form-model>
  38. </j-form-container>
  39. </a-spin>
  40. </template>
  41. <script>
  42. import { httpAction, getAction } from '@/api/manage'
  43. import { validateDuplicateValue } from '@/utils/util'
  44. export default {
  45. name: 'CostModelClPriceForm',
  46. components: {
  47. },
  48. props: {
  49. //表单禁用
  50. disabled: {
  51. type: Boolean,
  52. default: false,
  53. required: false
  54. }
  55. },
  56. data () {
  57. return {
  58. model:{
  59. },
  60. labelCol: {
  61. xs: { span: 24 },
  62. sm: { span: 5 },
  63. },
  64. wrapperCol: {
  65. xs: { span: 24 },
  66. sm: { span: 16 },
  67. },
  68. confirmLoading: false,
  69. validatorRules: {
  70. },
  71. url: {
  72. add: "/costModelClPrice/costModelClPrice/add",
  73. edit: "/costModelClPrice/costModelClPrice/edit",
  74. queryById: "/costModelClPrice/costModelClPrice/queryById"
  75. }
  76. }
  77. },
  78. computed: {
  79. formDisabled(){
  80. return this.disabled
  81. },
  82. },
  83. created () {
  84. //备份model原始值
  85. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  86. },
  87. methods: {
  88. add () {
  89. this.edit(this.modelDefault);
  90. },
  91. edit (record) {
  92. this.model = Object.assign({}, record);
  93. this.visible = true;
  94. },
  95. submitForm () {
  96. const that = this;
  97. // 触发表单验证
  98. this.$refs.form.validate(valid => {
  99. if (valid) {
  100. that.confirmLoading = true;
  101. let httpurl = '';
  102. let method = '';
  103. if(!this.model.id){
  104. httpurl+=this.url.add;
  105. method = 'post';
  106. }else{
  107. httpurl+=this.url.edit;
  108. method = 'put';
  109. }
  110. httpAction(httpurl,this.model,method).then((res)=>{
  111. if(res.success){
  112. that.$message.success(res.message);
  113. that.$emit('ok');
  114. }else{
  115. that.$message.warning(res.message);
  116. }
  117. }).finally(() => {
  118. that.confirmLoading = false;
  119. })
  120. }
  121. })
  122. },
  123. }
  124. }
  125. </script>