handleTask2.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <!-- 处理挖掘任务2(文件分配任务弹窗) -->
  3. <div class="handleTask2">
  4. <el-dialog ref="dialog" :title="title" :visible.sync="dialogVisible" width="900px" :before-close="handleClose" :append-to-body="true"
  5. :close-on-click-modal="false">
  6. <el-form :model="form" status-icon :rules="rules" ref="form" label-position="top" label-width="120px"
  7. class="demo-form" :disabled="!isLook">
  8. <el-form-item label="附件(已保存):">
  9. <el-table class="elTable" :data="tableData" border style="width: 100%"
  10. header-row-class-name="custom-table-header">
  11. <el-table-column prop="originalName" label="文件名称" align="center"></el-table-column>
  12. <el-table-column prop="createTime" label="文件上传时间" align="center"> </el-table-column>
  13. <el-table-column prop="type" label="文件类型" align="center"> </el-table-column>
  14. <el-table-column label="操作" align="center" width="140">
  15. <template slot-scope="scope">
  16. <div>
  17. <el-button @click="deleteFile(scope.row)" size="small" type="text" style="color: red;">删除</el-button>
  18. </div>
  19. </template>
  20. </el-table-column>
  21. </el-table>
  22. </el-form-item>
  23. <el-form-item label="附件(未保存):" prop="systemFileList">
  24. <myUpload :file-list="form.systemFileList" @on-change="onchangeFile" @on-remove="onRemove"
  25. style="height: 180px;" :autoUpload="true"></myUpload>
  26. </el-form-item>
  27. <el-form-item label="说明:">
  28. <el-input type="textarea" :rows="2" placeholder="请输入说明内容" v-model="form.description"></el-input>
  29. </el-form-item>
  30. </el-form>
  31. <span slot="footer" class="dialog-footer">
  32. <el-button @click="handleClose" size="small">取 消</el-button>
  33. <template>
  34. <div v-if="isLook" style="margin-left: 10px;">
  35. <el-button @click="handleSave" size="small" type="primary">保 存</el-button>
  36. <el-button @click="submit" size="small" type="primary">提交审核</el-button>
  37. </div>
  38. </template>
  39. </span>
  40. </el-dialog>
  41. <examine ref="examine" @taskForm="handleTaskForm" @isHandleSave="isHandleSave"></examine>
  42. </div>
  43. </template>
  44. <script>
  45. import examine from '@/views/components/dialog/examine.vue'
  46. export default {
  47. components: {
  48. examine,
  49. },
  50. props: {},
  51. data() {
  52. return {
  53. title: '',
  54. tableData: [],
  55. form: {
  56. systemFileList: [],
  57. },
  58. rules: {},
  59. dialogVisible: false,
  60. // auditTask: false,
  61. // 备注
  62. textarea: '',
  63. // 是否是处理任务?
  64. isLook: false,
  65. row: null,
  66. };
  67. },
  68. watch: {},
  69. computed: {},
  70. created() { },
  71. mounted() { },
  72. methods: {
  73. // 上传的文件监听
  74. onchangeFile(file, fileList) {
  75. if (file.guid) {
  76. let index = this.form.systemFileList.findIndex(item => {
  77. return item.uid == file.uid
  78. })
  79. if (index != -1) {
  80. this.form.systemFileList.splice(index, 1, file)
  81. }
  82. } else {
  83. this.form.systemFileList.push(file.raw)
  84. }
  85. },
  86. // 删除上传的文件
  87. onRemove(file, fileList) {
  88. let index = this.form.systemFileList.findIndex(item => {
  89. return item.uid == file.uid
  90. })
  91. if (index != -1) {
  92. this.form.systemFileList.splice(index, 1)
  93. }
  94. },
  95. //打开弹窗
  96. open(row, val) {
  97. this.row = row
  98. this.isLook = val
  99. this.title = '任务名称:' + row.name
  100. this.getTableList()
  101. this.dialogVisible = true
  102. },
  103. // 查询已保存的项目
  104. getTableList() {
  105. let params = {
  106. taskId: this.row.id
  107. }
  108. this.$api.getTaskHandleResult(params).then(res => {
  109. if (res.code == 200) {
  110. this.tableData = res.data.systemFileList
  111. }
  112. }).catch(error => {
  113. this.tableData = []
  114. })
  115. },
  116. // 删除文件
  117. deleteFile(row) {
  118. this.deleteFiles([row.id])
  119. },
  120. deleteFiles(ids) {
  121. this.$api.deleteAssoTaskFile(ids).then(res => {
  122. if (res.code == 200) {
  123. this.getTableList()
  124. this.$message.success('删除已保存的文件成功')
  125. }
  126. })
  127. },
  128. //关闭弹窗
  129. handleClose() {
  130. this.form = {
  131. systemFileList: []
  132. }
  133. this.dialogVisible = false
  134. },
  135. // 保存
  136. async handleSave(type) {
  137. // 判断文件是否都上传完毕
  138. if (this.form.systemFileList && this.form.systemFileList.length > 0) {
  139. this.form.fileGuids = []
  140. for (let i = 0; i < this.form.systemFileList.length; i++) {
  141. if (this.form.systemFileList[i].guid) {
  142. this.form.fileGuids.push(this.form.systemFileList[i].guid)
  143. } else {
  144. this.$message.error('文件未全部上传,请耐心等待')
  145. return false
  146. }
  147. }
  148. }
  149. this.form.taskId = this.row.id
  150. await this.$api.addTaskAuditResult(this.form).then(res => {
  151. if (res.code == 200) {
  152. this.$message.success('保存文件成功')
  153. if (!type) {
  154. this.handleClose()
  155. }
  156. }
  157. })
  158. },
  159. // 提交审核时有未保存的文件调用保存接口
  160. async isHandleSave() {
  161. if (this.form.systemFileList && this.form.systemFileList.length > 0) {
  162. await this.handleSave(1)
  163. }
  164. },
  165. //提交审核
  166. submit() {
  167. this.$refs.form.validate((valid) => {
  168. if (valid) {
  169. this.form.projectId = this.row.projectId//项目id
  170. this.form.id = this.row.id//当前文件分配任务的id
  171. this.$refs.examine.open(this.form, 5)
  172. }
  173. })
  174. },
  175. // 审核弹窗发送的值
  176. handleTaskForm(val) {
  177. this.$emit('isSuccess', '新增成功')
  178. this.handleClose()
  179. },
  180. },
  181. };
  182. </script>
  183. <style lang="scss">
  184. .handleTask2 {
  185. .el-dialog__body {
  186. padding: 10px 20px;
  187. }
  188. }
  189. </style>
  190. <style lang="scss" scoped>
  191. .handleTask2 {
  192. .handleTask2Dialog {
  193. background: red;
  194. }
  195. .upload-demo {
  196. float: right;
  197. margin-bottom: 10px;
  198. }
  199. .explain {
  200. margin-top: 10px;
  201. span {
  202. font-size: 16px;
  203. }
  204. }
  205. .dialog-footer {
  206. display: flex;
  207. justify-content: end;
  208. }
  209. }
  210. </style>