edit.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <div class="app-container">
  3. <div class="title-container">
  4. <breadcrumb id="breadcrumb-container" class="breadcrumb-container"/>
  5. </div>
  6. <y-detail-page-layout @save="handleCreate" :edit-status="false" v-loading="vLoading" element-loading-text="处理中。。。">
  7. <div style="padding-top: 30px;">
  8. <el-tabs v-model="activeName">
  9. <el-tab-pane label="日志信息" name="first">
  10. <el-form ref="postForm" :model="postForm" class="form-container" style="padding-left: 500px">
  11. <div>
  12. <div class="postInfo-container">
  13. <el-row>
  14. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  15. <el-form-item
  16. label="项目名称:"
  17. prop="itemName"
  18. label-width="180px"
  19. class="postInfo-container-item"
  20. >
  21. <el-input :value="postForm.itemName" class="filter-item" readonly disabled/>
  22. </el-form-item>
  23. </el-col>
  24. </el-row>
  25. </div>
  26. </div>
  27. <div>
  28. <div class="postInfo-container">
  29. <el-row>
  30. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  31. <el-form-item
  32. label="当前阶段:"
  33. prop="stageName"
  34. label-width="180px"
  35. class="postInfo-container-item"
  36. >
  37. <el-input :value="stageName" class="filter-item" readonly disabled/>
  38. </el-form-item>
  39. </el-col>
  40. </el-row>
  41. </div>
  42. </div>
  43. <div>
  44. <div class="postInfo-container">
  45. <el-row>
  46. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  47. <el-form-item
  48. label="日期:"
  49. prop="logDate"
  50. :rules="{required: true, message: '请选择日志日期', trigger: 'blur'}"
  51. label-width="180px"
  52. class="postInfo-container-item"
  53. >
  54. <el-date-picker
  55. v-model="postForm.logDate"
  56. type="date"
  57. value-format="yyyy-MM-dd"
  58. style="width: 100%"
  59. placeholder="选择日期"
  60. />
  61. </el-form-item>
  62. </el-col>
  63. </el-row>
  64. </div>
  65. </div>
  66. <div>
  67. <div class="postInfo-container">
  68. <el-row>
  69. <el-col :xs="24" :sm="12" :lg="10" :span="6">
  70. <el-form-item
  71. label="每日任务情况:"
  72. prop="taskSituation"
  73. :rules="{required: true, message: '请填写每日任务情况', trigger: 'blur'}"
  74. label-width="180px"
  75. class="postInfo-container-item"
  76. >
  77. <el-input type="textarea" v-model="postForm.taskSituation" class="filter-item" placeholder="200字符"/>
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. </div>
  82. </div>
  83. </el-form>
  84. </el-tab-pane>
  85. </el-tabs>
  86. </div>
  87. </y-detail-page-layout>
  88. </div>
  89. </template>
  90. <script>
  91. import Breadcrumb from '@/components/Breadcrumb'
  92. import YDetailPageLayout from '@/components/YDetailPageLayout'
  93. export default {
  94. name: 'itemDetail',
  95. components: {
  96. Breadcrumb,
  97. YDetailPageLayout
  98. },
  99. data() {
  100. return {
  101. type: 'logDetail',
  102. postForm: {},
  103. id: this.$route.query.id,
  104. stageName : this.$route.query.stageName,
  105. activeName: 'first',
  106. vLoading: false,
  107. listQuery:{},
  108. filterMethod(query, item) {
  109. return item.label.indexOf(query) > -1;
  110. },
  111. }
  112. },
  113. created() {
  114. this.getDetail();
  115. },
  116. mounted() {
  117. this.postForm.logDate = this.timeDefault;
  118. },
  119. computed: {
  120. timeDefault() {
  121. const date = new Date();
  122. const s1 = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate());
  123. return s1;
  124. }
  125. },
  126. methods: {
  127. // getDetail() {
  128. // if (this.itemId) {
  129. // this.$api.itemLog.detail(this.itemId).then(res => {
  130. // this.postForm = res.data;
  131. // });
  132. // }
  133. // },
  134. handleCreate() {
  135. if (this.postForm.taskSituation && this.postForm.taskSituation.length>200){
  136. this.$notify({
  137. title: '错误',
  138. message: '每日任务情况不超过200字符',
  139. type: 'error',
  140. duration: 2000
  141. });
  142. return;
  143. }
  144. this.vLoading = true;
  145. this.$refs.postForm.validate(valid => {
  146. if (valid) {
  147. if (this.id) {
  148. this.$api.itemLog.edit(Object.assign({}, this.postForm, {})).then(res => {
  149. if (res.code === 200) {
  150. this.$notify({
  151. title: '成功',
  152. message: '保存成功',
  153. type: 'success',
  154. duration: 2000
  155. });
  156. const back = this.$route.query.back;
  157. if (back) {
  158. this.$router.push(back)
  159. }
  160. this.initData();
  161. this.vLoading = false
  162. }
  163. }).catch(() => {
  164. this.vLoading = false
  165. })
  166. }
  167. }
  168. })
  169. },
  170. getDetail() {
  171. if (this.id) {
  172. this.$api.itemLog.detail(this.id).then(res => {
  173. this.postForm = res.data;
  174. });
  175. }
  176. },
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. </style>