|
@ -20,15 +20,43 @@ |
|
|
resizable |
|
|
resizable |
|
|
/> |
|
|
/> |
|
|
</t-card> |
|
|
</t-card> |
|
|
|
|
|
<t-drawer |
|
|
|
|
|
size="medium" |
|
|
|
|
|
closeOnEscKeydown |
|
|
|
|
|
sizeDraggable |
|
|
|
|
|
:visible="uploadVisible" |
|
|
|
|
|
header="上传excel" |
|
|
|
|
|
:footer="false" |
|
|
|
|
|
@close="handleClose" |
|
|
|
|
|
:onConfirm="handleConfirm" |
|
|
|
|
|
> |
|
|
|
|
|
<t-upload |
|
|
|
|
|
ref="uploadRef" |
|
|
|
|
|
:action="actionAddress" |
|
|
|
|
|
:headers="getHeaders()" |
|
|
|
|
|
v-model="files" |
|
|
|
|
|
status="success" |
|
|
|
|
|
theme="file-input" |
|
|
|
|
|
placeholder="未选择文件" |
|
|
|
|
|
@fail="handleFail" |
|
|
|
|
|
@success="handleSuccess" |
|
|
|
|
|
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" |
|
|
|
|
|
></t-upload> |
|
|
|
|
|
</t-drawer> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script lang="jsx"> |
|
|
<script lang="jsx"> |
|
|
import { taskListApi } from '@/api/task' |
|
|
|
|
|
|
|
|
import { taskListApi, delExcelByTaskIdApi, delTaskApi } from '@/api/task' |
|
|
|
|
|
import Cookie from '@/utils/cookie' |
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
|
|
|
files: [], |
|
|
|
|
|
tips: '上传格式仅支持xlsx', |
|
|
|
|
|
uploadVisible: false, |
|
|
data: [], |
|
|
data: [], |
|
|
|
|
|
currentTaskId: '', |
|
|
columns: [ |
|
|
columns: [ |
|
|
{ |
|
|
{ |
|
|
colKey: 'operatorName', |
|
|
colKey: 'operatorName', |
|
@ -66,10 +94,18 @@ export default { |
|
|
<t-button theme="danger" onClick={() => this.delTask(row.id)}> |
|
|
<t-button theme="danger" onClick={() => this.delTask(row.id)}> |
|
|
删除任务 |
|
|
删除任务 |
|
|
</t-button> |
|
|
</t-button> |
|
|
<t-button theme="danger" onClick={() => this.delExcel(row.id)}> |
|
|
|
|
|
|
|
|
<t-button |
|
|
|
|
|
theme="danger" |
|
|
|
|
|
disabled={row.canUpload} |
|
|
|
|
|
onClick={() => this.delExcel(row.id)} |
|
|
|
|
|
> |
|
|
删除excel |
|
|
删除excel |
|
|
</t-button> |
|
|
</t-button> |
|
|
<t-button theme="danger" onClick={() => this.uploadExcel(row.id)}> |
|
|
|
|
|
|
|
|
<t-button |
|
|
|
|
|
disabled={!row.canUpload} |
|
|
|
|
|
theme="danger" |
|
|
|
|
|
onClick={() => this.uploadExcel(row.id)} |
|
|
|
|
|
> |
|
|
上传Excel |
|
|
上传Excel |
|
|
</t-button> |
|
|
</t-button> |
|
|
</div> |
|
|
</div> |
|
@ -78,10 +114,59 @@ export default { |
|
|
], |
|
|
], |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
computed: { |
|
|
|
|
|
actionAddress() { |
|
|
|
|
|
return `${import.meta.env.VITE_BASE_URL}/upload/${this.currentTaskId}` |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
delTask(taskId) {}, |
|
|
|
|
|
delExcel(taskId) {}, |
|
|
|
|
|
uploadExcel(taskId) {}, |
|
|
|
|
|
|
|
|
handleSuccess({ response }) { |
|
|
|
|
|
console.log(response) |
|
|
|
|
|
if (response?.code == 200) { |
|
|
|
|
|
this.uploadVisible = false |
|
|
|
|
|
this.getTaskList() |
|
|
|
|
|
this.$message.success('上传成功') |
|
|
|
|
|
} else { |
|
|
|
|
|
this.$message.error(response?.msg) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
handleFail({ file }) { |
|
|
|
|
|
this.$message.error(`文件 ${file.name} 上传失败`) |
|
|
|
|
|
}, |
|
|
|
|
|
getHeaders() { |
|
|
|
|
|
return { |
|
|
|
|
|
Authorization: Cookie.getCookie('t'), |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
handleClose() { |
|
|
|
|
|
this.uploadVisible = false |
|
|
|
|
|
}, |
|
|
|
|
|
handleConfirm() { |
|
|
|
|
|
console.log(this.$refs) |
|
|
|
|
|
this.$refs.uploadRef.triggerUpload() |
|
|
|
|
|
}, |
|
|
|
|
|
async delTask(taskId) { |
|
|
|
|
|
const res = await delTaskApi(taskId) |
|
|
|
|
|
if (res?.code == 200) { |
|
|
|
|
|
if (res?.data?.result) { |
|
|
|
|
|
this.$message.success('删除任务成功') |
|
|
|
|
|
this.getTaskList() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
async delExcel(taskId) { |
|
|
|
|
|
const res = await delExcelByTaskIdApi(taskId) |
|
|
|
|
|
if (res?.code == 200) { |
|
|
|
|
|
if (res?.data?.result) { |
|
|
|
|
|
this.$message.success('删除该任务的excel计划表成功') |
|
|
|
|
|
this.getTaskList() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
uploadExcel(taskId) { |
|
|
|
|
|
this.currentTaskId = taskId |
|
|
|
|
|
this.uploadVisible = true |
|
|
|
|
|
}, |
|
|
async getTaskList() { |
|
|
async getTaskList() { |
|
|
const res = await taskListApi() |
|
|
const res = await taskListApi() |
|
|
if (res?.code == 200) { |
|
|
if (res?.code == 200) { |
|
|