addNotice1.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <!-- 添加公告信息 -->
  3. <div class="addWagonLoad">
  4. <PageTitle>返回</PageTitle>
  5. <div class="form" style="margin-right: 10rem">
  6. <dil-form :formId="389" v-model="form1" ref="from1"></dil-form>
  7. </div>
  8. <div class="button-box">
  9. <el-button @click="cancel">取消</el-button>
  10. <el-button type="primary" @click="makeSure">确定</el-button>
  11. </div>
  12. </div>
  13. </template>
  14. <script>
  15. import { getCookie } from '@/utils/util.js'
  16. import PageTitle from "@/components/Page/Title";
  17. export default {
  18. components: { PageTitle },
  19. data() {
  20. return {
  21. form1: {
  22. permission:"销售商"
  23. },
  24. value: undefined,
  25. };
  26. },
  27. mounted() {
  28. this.userId = getCookie('userId')
  29. /*console.log("新增")
  30. console.log(this.userId)
  31. //this.form1.insertTime=new Date()*/
  32. this.$set(this.form1, 'insertTime',new Date())
  33. this.information()
  34. },
  35. methods: {
  36. async information(){
  37. await this.axios.post("/api/v1/ams/queryName/"+this.userId)
  38. .then((res=>{
  39. console.log(res)
  40. let userName=res.data.data
  41. this.$set(this.form1, 'insertUsername',userName)
  42. }))
  43. },
  44. makeSure() {
  45. console.log(this.form1);
  46. let time=this.msToDate(this.form1.insertTime)
  47. let DilNotice = {
  48. noticeTitle:this.form1.noticeTitle,
  49. insertUsername:this.form1.insertUsername,
  50. noticeContent:this.form1.noticeContent,
  51. permissions:this.form1.permission,
  52. insertTime:time
  53. /*这里permissions拿的是描述也就是name值*/
  54. }
  55. this.axios
  56. .post(
  57. "/api/v1/ams/insertNotice",DilNotice
  58. )
  59. .then((res) => {
  60. this.$router.go(-1);
  61. });
  62. },
  63. msToDate(msec){
  64. let datetime = new Date(msec);
  65. let year = datetime.getFullYear();
  66. let month = datetime.getMonth();
  67. let date = datetime.getDate();
  68. let hour = datetime.getHours();
  69. let minute = datetime.getMinutes();
  70. let second = datetime.getSeconds();
  71. let result=year+
  72. '-'+
  73. ((month + 1) >= 10 ? (month + 1) : '0' + (month + 1)) +
  74. '-' +
  75. ((date + 1) < 10 ? '0' + date : date) +
  76. ' ' +
  77. ((hour + 1) < 10 ? '0' + hour : hour) +
  78. ':' +
  79. ((minute + 1) < 10 ? '0' + minute : minute) +
  80. ':' +
  81. ((second + 1) < 10 ? '0' + second : second);
  82. return result;
  83. },
  84. // 取消
  85. cancel() {
  86. this.$router.go(-1);
  87. },
  88. },
  89. };
  90. </script>
  91. <style lang='scss' scoped>
  92. .from {
  93. display: flex;
  94. align-items: center;
  95. justify-content: center;
  96. margin-top: 5px;
  97. margin-bottom: 20px;
  98. }
  99. .button-box{
  100. display: flex;
  101. text-align: center;
  102. align-items: center;
  103. justify-content: center;
  104. margin-top: 0.3125rem;
  105. margin-bottom: 1.25rem;
  106. }
  107. .form{
  108. .el-form{
  109. margin-top: 100px;
  110. margin-left: 200px;
  111. .preview-group{
  112. .el-form-item{
  113. width: 600px;
  114. height: 60px;
  115. }
  116. }
  117. }
  118. }
  119. </style>