| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <template>
- <div>
- <containerTitle :title="title"></containerTitle>
- <basic-container>
- <avue-crud
- ref="crud"
- :option="option"
- v-model="form"
- :data="fileData"
- @row-save="rowSave"
- @row-update="rowUpdate"
- @row-del="rowDel"
- :upload-after="uploadAfter"
- @saveColumn="saveColumn"
- :cell-style="cellStyle"
- >
- <template slot="menuLeft">
- <el-button
- type="primary"
- icon="el-icon-plus"
- size="small"
- @click.stop="$refs.crud.rowAdd()"
- :disabled="disabled"
- >上传</el-button
- >
- </template>
- <template slot="menu" slot-scope="{ row, index }">
- <el-button
- size="small"
- icon="el-icon-edit"
- type="text"
- @click="$refs.crud.rowEdit(row, index)"
- :disabled="disabled"
- >编 辑</el-button
- >
- <el-button
- size="small"
- icon="el-icon-delete"
- type="text"
- @click="rowDel(row, index)"
- :disabled="disabled"
- >删 除</el-button
- >
- </template>
- </avue-crud>
- </basic-container>
- </div>
- </template>
- <script>
- import option from "./config/uploadList.json";
- import { updateListRemove } from "@/api/uploadFile/upload-file";
- export default {
- name: "uploadfile",
- data() {
- return {
- form: {},
- fileData: [],
- option: {}
- };
- },
- props: {
- title: {
- type: String,
- default: "附件上传"
- },
- orderFilesList: {
- type: Array
- },
- disabled: {
- type: Boolean
- },
- delUrl: {
- type: String
- }
- },
- async created() {
- this.option = await this.getColumnData(this.getColumnName(35), option);
- },
- methods: {
- cellStyle() {
- return "padding:0;height:40px;";
- },
- //新增附件上传保存触发
- rowSave(row, done, loading) {
- this.fileData.push(row);
- done();
- },
- //修改附件上传触发
- rowUpdate(row, index, done, loading) {
- done(row);
- },
- //删除附件上传触发
- rowDel(row, index, donerowDel) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- if (row.id) {
- updateListRemove(row.id, this.delUrl).then(res => {
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.fileData.splice(index, 1);
- });
- } else {
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.fileData.splice(index, 1);
- }
- });
- },
- uploadAfter(res, done) {
- if (res.originalName) {
- this.form.fileName = this.form.fileName
- ? this.form.fileName
- : res.originalName;
- }
- done();
- },
- //提交数据的返回值
- submitData() {
- return this.fileData;
- },
- async saveColumn() {
- const inSave = await this.saveColumnData(
- this.getColumnName(35),
- this.option
- );
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }
- }
- },
- watch: {
- orderFilesList: function(rows) {
- this.fileData = rows;
- }
- }
- };
- </script>
- <style scoped lang="scss"></style>
|