detail.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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="true" 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="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" :autosize="{ minRows: 8, maxRows: 8}" 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: 'detail',
  102. postForm: {
  103. itemId: this.$route.query.id,
  104. userId: this.$store.getters.userInfo.id,
  105. logDate:null,
  106. stageId: this.$route.query.stageId,
  107. },
  108. itemId: this.$route.query.id,
  109. itemName: this.$route.query.itemName,
  110. stageName: this.$route.query.stageName,
  111. stageId: this.$route.query.stageId,
  112. activeName: 'first',
  113. vLoading: false,
  114. listQuery:{},
  115. filterMethod(query, item) {
  116. return item.label.indexOf(query) > -1;
  117. },
  118. }
  119. },
  120. created() {
  121. //this.getDetail();
  122. },
  123. mounted() {
  124. this.postForm.logDate = this.timeDefault;
  125. },
  126. computed: {
  127. timeDefault() {
  128. const date = new Date();
  129. const s1 = date.getFullYear() + "-" + (this.getZero(date.getMonth() + 1)) + "-" + this.getZero((date.getDate()));
  130. return s1;
  131. }
  132. },
  133. methods: {
  134. // getDetail() {
  135. // if (this.itemId) {
  136. // this.$api.itemLog.detail(this.itemId).then(res => {
  137. // this.postForm = res.data;
  138. // });
  139. // }
  140. // },
  141. getZero(num) {
  142. // 单数前面加0
  143. if (parseInt(num) < 10) {
  144. num = '0' + num;
  145. }
  146. return num;
  147. },
  148. handleCreate() {
  149. if (this.postForm.taskSituation && this.postForm.taskSituation.length>200){
  150. this.$notify({
  151. title: '错误',
  152. message: '每日任务情况不超过200字符',
  153. type: 'error',
  154. duration: 2000
  155. });
  156. return;
  157. }
  158. if (this.postForm.logDate>this.timeDefault){
  159. this.$notify({
  160. title: '错误',
  161. message: '日期选择错误,不能选择还未开始的日期。',
  162. type: 'error',
  163. duration: 2000
  164. });
  165. return;
  166. }
  167. this.$refs.postForm.validate(valid => {
  168. if (valid) {
  169. if (this.itemId) {
  170. this.$api.itemLog.add(Object.assign({}, this.postForm, {
  171. })).then(res => {
  172. if (res.code === 200) {
  173. this.$notify({
  174. title: '成功',
  175. message: '保存成功',
  176. type: 'success',
  177. duration: 2000
  178. });
  179. const back = this.$route.query.back;
  180. if (back) {
  181. this.$router.push(back)
  182. }
  183. this.initData();
  184. this.vLoading = false
  185. }
  186. }).catch(() => {
  187. this.vLoading = false
  188. })
  189. } else {
  190. this.$api.itemLog.add(Object.assign({}, this.postForm, {
  191. })).then(res => {
  192. if (res.code === 200) {
  193. this.$notify({
  194. title: '成功',
  195. message: '新增成功',
  196. type: 'success',
  197. duration: 2000
  198. });
  199. const back = this.$route.query.back;
  200. if (back) {
  201. this.$router.push(back)
  202. }
  203. this.initData();
  204. this.vLoading = false
  205. }
  206. }).catch(() => {
  207. this.vLoading = false
  208. })
  209. }
  210. }
  211. })
  212. },
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. </style>