handleTask2.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. // systemFileList: [{ required: true, message: '请选择附件', trigger: 'blur' },],
  60. },
  61. dialogVisible: false,
  62. // auditTask: false,
  63. // 备注
  64. textarea: '',
  65. // 是否是处理任务?
  66. isLook: false,
  67. row: null,
  68. };
  69. },
  70. watch: {},
  71. computed: {},
  72. created() { },
  73. mounted() { },
  74. methods: {
  75. // 上传的文件监听
  76. onchangeFile(file, fileList) {
  77. if (file.guid) {
  78. let index = this.form.systemFileList.findIndex(item => {
  79. return item.uid == file.uid
  80. })
  81. if (index != -1) {
  82. this.form.systemFileList.splice(index, 1, file)
  83. }
  84. } else {
  85. this.form.systemFileList.push(file.raw)
  86. }
  87. },
  88. // 删除上传的文件
  89. onRemove(file, fileList) {
  90. let index = this.form.systemFileList.findIndex(item => {
  91. return item.uid == file.uid
  92. })
  93. if (index != -1) {
  94. this.form.systemFileList.splice(index, 1)
  95. }
  96. },
  97. //打开弹窗
  98. open(row, val) {
  99. // let row = JSON.parse(JSON.stringify(row))
  100. // if(this.form.id){
  101. // this.title = '编辑任务'
  102. // }else{
  103. // this.title = '创建任务'
  104. // }
  105. this.row = row
  106. this.isLook = val
  107. this.title = '任务名称:' + row.name
  108. this.getTableList()
  109. this.dialogVisible = true
  110. },
  111. // 查询已保存的项目
  112. getTableList() {
  113. let params = {
  114. taskId: this.row.id
  115. }
  116. this.$api.getTaskHandleResult(params).then(res => {
  117. if (res.code == 200) {
  118. this.tableData = res.data.systemFileList
  119. }
  120. }).catch(error => {
  121. this.tableData=[]
  122. })
  123. },
  124. // 删除文件
  125. deleteFile(row) {
  126. this.deleteFiles([row.id])
  127. },
  128. deleteFiles(ids) {
  129. this.$api.deleteAssoTaskFile(ids).then(res => {
  130. if (res.code == 200) {
  131. this.getTableList()
  132. this.$message.success('删除已保存的文件成功')
  133. }
  134. })
  135. },
  136. //关闭弹窗
  137. handleClose() {
  138. this.form = {
  139. systemFileList: []
  140. }
  141. this.dialogVisible = false
  142. },
  143. // 保存
  144. async handleSave(type) {
  145. // 判断文件是否都上传完毕
  146. if (this.form.systemFileList && this.form.systemFileList.length > 0) {
  147. this.form.fileGuids = []
  148. for (let i = 0; i < this.form.systemFileList.length; i++) {
  149. if (this.form.systemFileList[i].guid) {
  150. this.form.fileGuids.push(this.form.systemFileList[i].guid)
  151. } else {
  152. this.$message.error('文件未全部上传,请耐心等待')
  153. return false
  154. }
  155. }
  156. }
  157. this.form.taskId = this.row.id
  158. await this.$api.addTaskAuditResult(this.form).then(res => {
  159. if (res.code == 200) {
  160. this.$message.success('保存文件成功')
  161. if (!type) {
  162. this.handleClose()
  163. }
  164. }
  165. })
  166. },
  167. // 提交审核时有未保存的文件调用保存接口
  168. async isHandleSave() {
  169. if (this.form.systemFileList && this.form.systemFileList.length > 0) {
  170. await this.handleSave(1)
  171. }
  172. },
  173. //提交审核
  174. submit() {
  175. this.$refs.form.validate((valid) => {
  176. if (valid) {
  177. this.form.projectId = this.row.projectId//项目id
  178. this.form.id = this.row.id//当前文件分配任务的id
  179. this.$refs.examine.open(this.form, 5)
  180. }
  181. })
  182. },
  183. // 审核弹窗发送的值
  184. handleTaskForm(val) {
  185. this.$emit('isSuccess', '新增成功')
  186. this.handleClose()
  187. },
  188. },
  189. };
  190. </script>
  191. <style lang="scss">
  192. .handleTask2 {
  193. .el-dialog__body {
  194. padding: 10px 20px;
  195. }
  196. }
  197. </style>
  198. <style lang="scss" scoped>
  199. .handleTask2 {
  200. .handleTask2Dialog {
  201. background: red;
  202. }
  203. .upload-demo {
  204. float: right;
  205. margin-bottom: 10px;
  206. }
  207. .explain {
  208. margin-top: 10px;
  209. span {
  210. font-size: 16px;
  211. }
  212. }
  213. .dialog-footer {
  214. display: flex;
  215. justify-content: end;
  216. }
  217. }
  218. </style>