detail.vue 7.4 KB

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