SubmissionForm.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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="equipmentids">
  8. <j-search-select-tag v-model="model.equipmentids" dict="tpm_equipment,equipmentname,id" placeholder="请选择检定设备" mode="multiple"/>
  9. </a-form-model-item>
  10. </a-col>
  11. <a-col :span="24">
  12. <a-form-model-item label="送检负责人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="verificatePerson">
  13. <!-- <a-input v-model="model.verificatePerson" placeholder="请输入送检负责人" ></a-input> -->
  14. <j-dict-select-tag v-model="model.verificatePerson" placeholder="请选择负责人" dictCode="sys_user,realname,username"/>
  15. </a-form-model-item>
  16. </a-col>
  17. <a-col :span="24">
  18. <a-form-model-item label="检定方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="verificateMethod">
  19. <j-dict-select-tag type="list" v-model="model.verificateMethod" dictCode="verificate_method" placeholder="请选择检定方式" />
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :span="24">
  23. <a-form-model-item label="检定单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="verificateClientId">
  24. <j-search-select-tag v-model="model.verificateClientId" dict="base_client,client_name,id" placeholder="请选择检定单位" />
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :span="24">
  28. <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
  29. <!-- <a-input v-model="model.remark" placeholder="请输入备注" ></a-input> -->
  30. <a-textarea v-model="model.remark" rows="3" placeholder="请输入备注" />
  31. </a-form-model-item>
  32. </a-col>
  33. </a-row>
  34. </a-form-model>
  35. </j-form-container>
  36. </a-spin>
  37. </template>
  38. <script>
  39. import { httpAction, getAction } from '@/api/manage'
  40. import { validateDuplicateValue } from '@/utils/util'
  41. export default {
  42. name: 'SubmissionForm',
  43. components: {
  44. },
  45. props: {
  46. //表单禁用
  47. disabled: {
  48. type: Boolean,
  49. default: false,
  50. required: false
  51. }
  52. },
  53. data () {
  54. return {
  55. model:{
  56. },
  57. labelCol: {
  58. xs: { span: 24 },
  59. sm: { span: 5 },
  60. },
  61. wrapperCol: {
  62. xs: { span: 24 },
  63. sm: { span: 16 },
  64. },
  65. confirmLoading: false,
  66. validatorRules: {
  67. },
  68. url: {
  69. add: "/cmmsSubmission/cmmsSubmission/add",
  70. edit: "/cmmsSubmission/cmmsSubmission/edit",
  71. queryById: "/cmmsSubmission/cmmsSubmission/queryById"
  72. }
  73. }
  74. },
  75. computed: {
  76. formDisabled(){
  77. return this.disabled
  78. },
  79. },
  80. created () {
  81. //备份model原始值
  82. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  83. },
  84. methods: {
  85. add () {
  86. this.edit(this.modelDefault);
  87. },
  88. edit (record) {
  89. this.model = Object.assign({}, record);
  90. this.visible = true;
  91. },
  92. submitForm () {
  93. const that = this;
  94. // 触发表单验证
  95. this.$refs.form.validate(valid => {
  96. if (valid) {
  97. that.confirmLoading = true;
  98. let httpurl = '';
  99. let method = '';
  100. if(!this.model.id){
  101. httpurl+=this.url.add;
  102. method = 'post';
  103. }else{
  104. httpurl+=this.url.edit;
  105. method = 'put';
  106. }
  107. httpAction(httpurl,this.model,method).then((res)=>{
  108. if(res.success){
  109. that.$message.success(res.message);
  110. that.$emit('ok');
  111. }else{
  112. that.$message.warning(res.message);
  113. }
  114. }).finally(() => {
  115. that.confirmLoading = false;
  116. })
  117. }
  118. })
  119. },
  120. }
  121. }
  122. </script>