StatusComponent.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div>
  3. <el-select
  4. v-model="status"
  5. :class="{
  6. 'status_color': status === 0,
  7. 'status_color2': status === 3,
  8. 'status_color5': status === 2,
  9. 'status_color1': status === 4,
  10. 'status_color3': status === 5
  11. }"
  12. class="public_botton"
  13. size="mini"
  14. @change="blurEvent(status)"
  15. >
  16. <el-option v-for="item in bugStatusList(status)" :key="item.code" :label="item.name" :value="item.code" />
  17. </el-select>
  18. <el-dialog
  19. v-if="statusDialogVisible"
  20. :visible.sync="statusDialogVisible"
  21. width="30%"
  22. :title="statusDialogTitle"
  23. class="public_task"
  24. :append-to-body="true"
  25. :close-on-click-modal="false"
  26. @close="modalClose"
  27. >
  28. <div class="blueStripe" />
  29. <el-form ref="statusDialogForm" label-width="110px" label-position="left" :model="statusDialogForm" :rules="rules">
  30. <el-form-item v-if="statusDialogTitle === '待测试'" label="修复结果" prop="repairResult" class="bug_manage_dialog">
  31. <el-select v-model="statusDialogForm.repairResult" style="width: 100%">
  32. <el-option v-for="item in repairResultEnumList" :key="item.code" :label="item.name" :value="item.code" />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item v-if="statusDialogTitle === '待测试' || statusDialogTitle === '已完成'" label="缺陷原因" prop="bugReason" class="bug_manage_dialog">
  36. <el-select v-model="statusDialogForm.bugReason" style="width: 100%">
  37. <el-option v-for="item in bugReasonEnumList" :key="item.code" :label="item.name" :value="item.code" />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item v-if="statusDialogTitle === '待测试'" label="修复方式" class="bug_manage_dialog bug_manage_dialog_fixMethod">
  41. <el-input v-model="statusDialogForm.reasonOrDesc" type="textarea" placeholder="请输入具体原因,得出结论的过程,具体修复过程或方式" maxlength="300" show-word-limit rows="4" />
  42. </el-form-item>
  43. <el-form-item v-if="statusDialogTitle === '已完成'" label="修复结果" prop="repairResult" class="bug_manage_dialog">
  44. <el-select v-model="statusDialogForm.repairResult" style="width: 100%">
  45. <el-option v-for="item in repairResultEnumList" :key="item.code" :label="item.name" :value="item.code" />
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item v-if="statusDialogTitle === 'Reopen'" label="Reopen原因" prop="reasonOrDesc" class="bug_manage_dialog">
  49. <el-input v-model="statusDialogForm.reasonOrDesc" type="textarea" placeholder="请输入Reopen" maxlength="300" show-word-limit rows="4" />
  50. </el-form-item>
  51. <el-form-item v-if="statusDialogTitle === 'Hold'" label="Hold原因" prop="reasonOrDesc" class="bug_manage_dialog">
  52. <el-input v-model="statusDialogForm.reasonOrDesc" type="textarea" maxlength="300" show-word-limit rows="4" />
  53. </el-form-item>
  54. </el-form>
  55. <template v-slot:footer>
  56. <el-button size="small" @click="modalClose()">取 消</el-button>
  57. <el-button size="small" type="primary" @click="statusDialogConfirm">确 定</el-button>
  58. </template>
  59. </el-dialog>
  60. </div>
  61. </template>
  62. <script>
  63. import { bugUpdate, bugGetEnum } from '@/api/defectManage'
  64. import '@/styles/PublicStyle/index.scss'
  65. export default {
  66. props: {
  67. title: { type: String, default: null }, // 标题
  68. statusData: { type: Number, default: null }, // 选择的当前状态
  69. statusRow: { type: Object, default: null } // 当前行数据
  70. },
  71. data() {
  72. return {
  73. userData: { id: '', ename: localStorage.getItem('username'), name: localStorage.getItem('realname') },
  74. status: this.statusData, // 状态的code
  75. statusDialogVisible: false, // dialog
  76. bugEnumList: [], // 状态option
  77. bugReasonEnumList: [], // 缺陷原因
  78. repairResultEnumList: [], // 修复结果
  79. statusDialogTitle: '', // 状态Name
  80. statusDialogForm: {}, // 表单
  81. staData: {},
  82. statusCode: '',
  83. rules: {
  84. bugReason: [{ required: true, message: '请选择缺陷原因', trigger: ['blur', 'change'] }],
  85. repairResult: [{ required: true, message: '请选择修复结果', trigger: ['blur', 'change'] }],
  86. reasonOrDesc: [{ required: true, message: '请输入Reopen原因', trigger: ['blur', 'change'] }]
  87. }
  88. }
  89. },
  90. created() {
  91. this.bugListSelect()
  92. },
  93. methods: {
  94. blurEvent(status) { // 修改状态为0
  95. this.statusCode = status
  96. if (status === 0) {
  97. this.statusRow.status = status
  98. bugUpdate({ bugBaseInfo: this.statusRow, user: this.userData }).then(res => {
  99. this.statusRow.isSelected = !this.statusRow.isSelected
  100. if (res.code === 200) {
  101. this.$emit('getBugList')
  102. }
  103. this.$message({ message: res.msg, type: res.msg })
  104. })
  105. return
  106. }
  107. let data = ''
  108. this.bugEnumList.map(item => {
  109. item.code === status ? data = item.name : ''
  110. })
  111. this.statusDialogTitle = data
  112. this.statusDialogVisible = true
  113. },
  114. modalClose() { // 关闭dialog
  115. this.statusDialogVisible = false
  116. this.status = this.statusData
  117. },
  118. statusDialogConfirm() { // 点击确定 验证 修改
  119. this.$refs.statusDialogForm.validate((valid) => {
  120. if (valid) {
  121. this.staData = this.statusRow
  122. this.staData.status = this.statusCode
  123. this.staData.reasonOrDesc = this.statusDialogForm.reasonOrDesc
  124. this.staData.repairResult = this.statusDialogForm.repairResult
  125. this.staData.bugReason = this.statusDialogForm.bugReason
  126. const objData = { bugBaseInfo: this.staData, user: this.userData }
  127. alert()
  128. bugUpdate(objData).then(res => {
  129. if (res.code === 200) {
  130. this.statusDialogVisible = false
  131. this.statusDialogForm = {}
  132. } else if (res.code !== 200) {
  133. this.$emit('getBugList')
  134. }
  135. this.$message({ message: res.msg, type: res.msg })
  136. })
  137. }
  138. })
  139. },
  140. bugStatusList(status) { // 不同状态返回不同的option
  141. if (status === 0) {
  142. return this.bugEnumList.filter(item => {
  143. return item.code === 0 || item.code === 2 || item.code === 5
  144. })
  145. }
  146. if (status === 2) {
  147. return this.bugEnumList.filter(item => {
  148. return item.code === 2 || item.code === 3 || item.code === 4
  149. })
  150. }
  151. if (status === 3) {
  152. return this.bugEnumList.filter(item => {
  153. return item.code === 3
  154. })
  155. }
  156. if (status === 4) {
  157. return this.bugEnumList.filter(item => {
  158. return item.code === 2 || item.code === 5 || item.code === 4
  159. })
  160. }
  161. if (status === 5) {
  162. return this.bugEnumList.filter(item => {
  163. return item.code === 5 || item.code === 2
  164. })
  165. }
  166. },
  167. bugListSelect() { // 获取下拉数据
  168. bugGetEnum().then(res => {
  169. this.bugEnumList = res.data.bugEnumList // status
  170. this.repairResultEnumList = res.data.repairResultEnumList // 修复结果
  171. this.bugReasonEnumList = res.data.bugReasonEnumList
  172. })
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="scss">
  178. .btns .el-input--suffix .el-input__inner {
  179. padding-right: 10px;
  180. padding-left: 10px;
  181. width: 73px;
  182. }
  183. </style>