UReportFileModal.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <a-modal
  3. :title="title"
  4. :width="800"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. @ok="handleOk"
  8. @cancel="handleCancel"
  9. cancelText="关闭">
  10. <a-spin :spinning="confirmLoading">
  11. <a-form :form="form">
  12. <a-form-item
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. label="报表名称">
  16. <a-input placeholder="请输入报表名称" v-decorator="['name', {}]" />
  17. </a-form-item>
  18. <a-form-item
  19. :labelCol="labelCol"
  20. :wrapperCol="wrapperCol"
  21. label="报表内容">
  22. <a-input placeholder="请输入报表内容" v-decorator="['content', {}]" />
  23. </a-form-item>
  24. </a-form>
  25. </a-spin>
  26. </a-modal>
  27. </template>
  28. <script>
  29. import { httpAction } from '@/api/manage'
  30. import pick from 'lodash.pick'
  31. import moment from "moment"
  32. export default {
  33. name: "UReportFileModal",
  34. data () {
  35. return {
  36. title:"操作",
  37. visible: false,
  38. model: {},
  39. labelCol: {
  40. xs: { span: 24 },
  41. sm: { span: 5 },
  42. },
  43. wrapperCol: {
  44. xs: { span: 24 },
  45. sm: { span: 16 },
  46. },
  47. confirmLoading: false,
  48. form: this.$form.createForm(this),
  49. validatorRules:{
  50. },
  51. url: {
  52. add: "/ctop/uReportFile/add",
  53. edit: "/ctop/uReportFile/edit",
  54. },
  55. }
  56. },
  57. created () {
  58. },
  59. methods: {
  60. add () {
  61. this.edit({});
  62. },
  63. edit (record) {
  64. this.form.resetFields();
  65. this.model = Object.assign({}, record);
  66. this.visible = true;
  67. this.$nextTick(() => {
  68. this.form.setFieldsValue(pick(this.model,'name','content'))
  69. //时间格式化
  70. });
  71. },
  72. close () {
  73. this.$emit('close');
  74. this.visible = false;
  75. },
  76. handleOk () {
  77. const that = this;
  78. // 触发表单验证
  79. this.form.validateFields((err, values) => {
  80. if (!err) {
  81. that.confirmLoading = true;
  82. let httpurl = '';
  83. let method = '';
  84. if(!this.model.id){
  85. httpurl+=this.url.add;
  86. method = 'post';
  87. }else{
  88. httpurl+=this.url.edit;
  89. method = 'put';
  90. }
  91. let formData = Object.assign(this.model, values);
  92. //时间格式化
  93. console.log(formData)
  94. httpAction(httpurl,formData,method).then((res)=>{
  95. if(res.success){
  96. that.$message.success(res.message);
  97. that.$emit('ok');
  98. }else{
  99. that.$message.warning(res.message);
  100. }
  101. }).finally(() => {
  102. that.confirmLoading = false;
  103. that.close();
  104. })
  105. }
  106. })
  107. },
  108. handleCancel () {
  109. this.close()
  110. },
  111. }
  112. }
  113. </script>
  114. <style lang="less" scoped>
  115. </style>