Inspect1.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div class='flex flex-justify-start flex-align-center flex-col'>
  3. <span class='bold full-width text-left mt-20'>{{ info.dictValue }}</span>
  4. <div style='width: 95%;' class='mt-20'>
  5. <avue-crud
  6. :option="option"
  7. :data="data"
  8. ref="crud"
  9. v-model="form"
  10. v-model:page='page'
  11. :table-loading="loading"
  12. :before-open="beforeOpen"
  13. @current-change="currentChange"
  14. @size-change="sizeChange"
  15. @refresh-change="refreshChange"
  16. @row-del="rowDel"
  17. @row-save="rowSave"
  18. @row-update="rowUpdate">
  19. <template #menu="{row}">
  20. <el-button v-if='row.hasReport' text type='primary' icon='el-icon-plus' @click='report(row)'>
  21. {{ row.isReport === 1 ? "已上报" : "上报" }}
  22. </el-button>
  23. </template>
  24. </avue-crud>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import option1 from '@/views/home/component/inspect/option1.js'
  30. import option2 from '@/views/home/component/inspect/option2.js'
  31. import option3 from '@/views/home/component/inspect/option3.js'
  32. import option4 from '@/views/home/component/inspect/option4.js'
  33. import option5 from '@/views/home/component/inspect/option5.js'
  34. export default {
  35. name: 'Inspect1',
  36. props: {
  37. info: {
  38. type: Object,
  39. default: null
  40. }
  41. },
  42. watch: {
  43. info: {
  44. handler (val) {
  45. if (val) {
  46. this.changeColum(val.dictKey)
  47. }
  48. },
  49. immediate: true
  50. }
  51. },
  52. data () {
  53. return {
  54. loading: false,
  55. form: {},
  56. data: [],
  57. projectId: '',
  58. page: {
  59. size: 10,
  60. current: 1
  61. },
  62. option: {
  63. align: 'center',
  64. menuAlign: 'center',
  65. addBtn: true,
  66. refreshBtn: false,
  67. columnBtn: false,
  68. labelWidth: 140,
  69. border: true,
  70. column: [
  71. {
  72. label: '工作推荐情况描述',
  73. prop: 'description',
  74. span: 24,
  75. type: 'textarea'
  76. },
  77. {
  78. label: '填报时间',
  79. prop: 'createTime',
  80. display: false
  81. },
  82. {
  83. label: '是否已经上报',
  84. prop: 'isReport',
  85. type: 'select',
  86. display: false,
  87. dicData: [
  88. {
  89. label: '否',
  90. value: 0
  91. },
  92. {
  93. label: '是',
  94. value: 1
  95. }
  96. ]
  97. },
  98. {
  99. label: '上报时间',
  100. prop: 'reportTime',
  101. display: false
  102. }
  103. ]
  104. }
  105. }
  106. },
  107. created () {
  108. this.projectId = this.$route.query.id
  109. this.onLoad()
  110. },
  111. methods: {
  112. changeColum (key) {
  113. if (key === '1') {
  114. this.option = option1
  115. } else if (key === '2') {
  116. this.option = option2
  117. } else if (key === '3') {
  118. this.option = option3
  119. } else if (key === '4') {
  120. this.option = option4
  121. } else if (key === '5') {
  122. this.option = option5
  123. }
  124. },
  125. add () {
  126. this.$refs.crud.rowAdd()
  127. },
  128. report (row) {
  129. if (row.isReport === 1) {
  130. this.$message.error('该记录已经上报')
  131. return
  132. }
  133. this.$confirm('是否确定进行上报操作?', {
  134. confirmButtonText: '确定',
  135. cancelButtonText: '取消',
  136. type: 'warning'
  137. }).then(() => {
  138. this.loading = true
  139. this.$api.inspect.report({ projectInspectorId: row.id }).then(res => {
  140. this.loading = false
  141. if (res.code === 200) {
  142. this.onLoad()
  143. } else {
  144. this.$message.error(res.msg)
  145. }
  146. })
  147. })
  148. },
  149. onLoad () {
  150. const data = {
  151. projectId: this.projectId,
  152. status: this.info.dictKey
  153. }
  154. this.loading = true
  155. this.$api.inspect.list(Object.assign(this.page, data)).then(res => {
  156. this.data = res.data.records
  157. this.page.total = res.data.total
  158. if (this.data.length > 0) {
  159. const hasReport = this.data[0].hasReport
  160. if (!hasReport) {
  161. // hasReport === false 表示未最后一级,不需要上报或者其他操作
  162. const index = this.option.column.findIndex(e => e.prop === 'reportTime')
  163. this.option.column[index].hide = true
  164. }
  165. const sort = this.data[0].sort
  166. if (sort !== 0) { // sort ===0 第一级,填报内容的第一级用户
  167. this.option.delBtn = false
  168. this.option.editBtn = false
  169. const index = this.option.column.findIndex(e => e.prop === 'reportDeptName')
  170. this.option.column[index].hide = false
  171. } else { // 第一级部门,不显示上报部门
  172. const index = this.option.column.findIndex(e => e.prop === 'reportDeptName')
  173. this.option.column[index].hide = true
  174. }
  175. }
  176. }).finally(() => {
  177. this.loading = false
  178. })
  179. },
  180. beforeOpen (done, type) {
  181. if (['view', 'edit'].includes(type)) {
  182. }
  183. done()
  184. },
  185. getDetail (res) {
  186. this.$api.inspect.detail({ id: res.id }).then(res => {
  187. if (res.code === 200) {
  188. this.form = res.data
  189. }
  190. })
  191. },
  192. currentChange (currentPage) {
  193. console.log(currentPage)
  194. this.page.current = currentPage
  195. this.refreshChange()
  196. },
  197. sizeChange (pageSize) {
  198. this.page.size = pageSize
  199. this.refreshChange()
  200. },
  201. refreshChange () {
  202. this.onLoad()
  203. },
  204. rowSave (row, done, loading) {
  205. const data = {
  206. projectId: this.projectId,
  207. status: this.info.dictKey
  208. }
  209. this.$api.inspect.submint(Object.assign(row, data)).then((res) => {
  210. if (res.code === 200) {
  211. this.$message.success(res.msg)
  212. } else {
  213. this.$message.error(res.msg)
  214. }
  215. done(row)
  216. this.onLoad()
  217. }, error => {
  218. window.console.log(error)
  219. loading()
  220. })
  221. },
  222. rowUpdate (row, index, done, loading) {
  223. const data = {
  224. projectId: this.projectId
  225. }
  226. this.$api.inspect.update(Object.assign(row, data)).then((res) => {
  227. if (res.code === 200) {
  228. this.$message.success(res.msg)
  229. } else {
  230. this.$message.error(res.msg)
  231. }
  232. done(row)
  233. this.onLoad()
  234. }, error => {
  235. window.console.log(error)
  236. loading()
  237. })
  238. },
  239. rowDel (row, index, done) {
  240. this.$confirm('确定将选择数据删除?', {
  241. confirmButtonText: '确定',
  242. cancelButtonText: '取消',
  243. type: 'warning'
  244. }).then(() => {
  245. return this.$api.inspect.remove({ ids: row.id })
  246. }).then(() => {
  247. this.$message({
  248. type: 'success',
  249. message: '操作成功!'
  250. })
  251. // 数据回调进行刷新
  252. done(row)
  253. this.onLoad()
  254. }).catch(() => {
  255. })
  256. }
  257. }
  258. }
  259. </script>
  260. <style scoped>
  261. </style>