cbdf57e6b6f78f4a63e9640b359fe4d3e4a1a02e.svn-base 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <j-modal
  3. :title="title"
  4. :width="width"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. switchFullscreen
  8. @ok="handleOk"
  9. @cancel="handleCancel"
  10. cancelText="关闭">
  11. <a-spin :spinning="confirmLoading">
  12. <a-form-model ref="form" :model="model" :rules="validatorRules">
  13. <a-row>
  14. <a-col :span="24">
  15. <a-form-model-item label="项目编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmbh">
  16. <a-input v-model="model.xmbh" placeholder="请输入项目编号" ></a-input>
  17. </a-form-model-item>
  18. </a-col>
  19. <a-col :span="24">
  20. <a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmmc">
  21. <a-input v-model="model.xmmc" placeholder="请输入项目名称" ></a-input>
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :span="24">
  25. <a-form-model-item label="采集人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cjr">
  26. <a-input v-model="model.cjr" placeholder="请输入采集人" ></a-input>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :span="24">
  30. <a-form-model-item label="采集时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cjsj">
  31. <j-date placeholder="请选择采集时间" v-model="model.cjsj" style="width: 100%" />
  32. </a-form-model-item>
  33. </a-col>
  34. </a-row>
  35. </a-form-model>
  36. </a-spin>
  37. </j-modal>
  38. </template>
  39. <script>
  40. import { httpAction } from '@/api/manage'
  41. import { validateDuplicateValue } from '@/utils/util'
  42. export default {
  43. name: "RmXxcjModal",
  44. components: {
  45. },
  46. data () {
  47. return {
  48. title:"操作",
  49. width:800,
  50. visible: false,
  51. model:{
  52. },
  53. labelCol: {
  54. xs: { span: 24 },
  55. sm: { span: 5 },
  56. },
  57. wrapperCol: {
  58. xs: { span: 24 },
  59. sm: { span: 16 },
  60. },
  61. confirmLoading: false,
  62. validatorRules: {
  63. },
  64. url: {
  65. add: "/hzz.xxcj/rmXxcj/add",
  66. edit: "/hzz.xxcj/rmXxcj/edit",
  67. }
  68. }
  69. },
  70. created () {
  71. //备份model原始值
  72. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  73. },
  74. methods: {
  75. add () {
  76. this.edit(this.modelDefault);
  77. },
  78. edit (record) {
  79. this.model = Object.assign({}, record);
  80. this.visible = true;
  81. },
  82. close () {
  83. this.$emit('close');
  84. this.visible = false;
  85. this.$refs.form.clearValidate();
  86. },
  87. handleOk () {
  88. const that = this;
  89. // 触发表单验证
  90. this.$refs.form.validate(valid => {
  91. if (valid) {
  92. that.confirmLoading = true;
  93. let httpurl = '';
  94. let method = '';
  95. if(!this.model.id){
  96. httpurl+=this.url.add;
  97. method = 'post';
  98. }else{
  99. httpurl+=this.url.edit;
  100. //method = 'put';
  101. method = 'post';
  102. }
  103. httpAction(httpurl,this.model,method).then((res)=>{
  104. if(res.success){
  105. that.$message.success(res.message);
  106. that.$emit('ok');
  107. }else{
  108. that.$message.warning(res.message);
  109. }
  110. }).finally(() => {
  111. that.confirmLoading = false;
  112. that.close();
  113. })
  114. }else{
  115. return false
  116. }
  117. })
  118. },
  119. handleCancel () {
  120. this.close()
  121. },
  122. }
  123. }
  124. </script>