add.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div>
  3. <el-button type="warning" size="small" @click="btnClick()" v-if="type == 'save'">
  4. <img src="@/assets/set.png" alt="" style="margin-right:10px">
  5. 保存
  6. </el-button>
  7. <el-button type="primary" size="small" @click="dialogVisible=true" v-else>
  8. 新建素材
  9. </el-button>
  10. <el-dialog
  11. title="新建素材"
  12. :visible.sync="dialogVisible"
  13. width="660px"
  14. :before-close="handleClose"
  15. append-to-body>
  16. <div class="content">
  17. <img src="@/assets/upload_icon/img.png" alt="" @click="add(1)">
  18. <img src="@/assets/upload_icon/video.png" alt="" @click="add(2)">
  19. <img src="@/assets/upload_icon/text-img.png" alt="" @click="add(3)">
  20. </div>
  21. </el-dialog>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'save',
  27. data() {
  28. return {
  29. dialogVisible:false
  30. };
  31. },
  32. props: {
  33. type: {
  34. default() {
  35. return ''
  36. }
  37. }
  38. },
  39. computed: {
  40. },
  41. watch: {
  42. },
  43. methods: {
  44. /* 新增并编辑素材 */
  45. async add(type) {
  46. let classid = '9999' + JSON.parse(window.sessionStorage.getItem("active_account")).userid;
  47. let res = await this.$api.requested({
  48. "classname": "webmanage.saletool.sharematerial.sharematerial",
  49. "method": "insertOrUpdate",
  50. "content": {
  51. "title": "",
  52. "sat_sharematerial_classid": classid,
  53. "notes": "",
  54. "tag": [],
  55. "canfiledownload": 1,
  56. "content": "",
  57. "sat_sharematerialid": 0,
  58. type
  59. }
  60. })
  61. if (res.msg != '成功') return this.$message.error(res.data);
  62. window.sessionStorage.setItem('newMaterial', JSON.stringify(res.data));
  63. this.$store.dispatch('DrawerShowChange',true)
  64. this.$router.push({
  65. path: '/upload_archives',
  66. query: {
  67. id: res.data.sat_sharematerialid
  68. }
  69. });
  70. },
  71. btnClick(){
  72. this.$emit("btnClick")
  73. },
  74. handleClose() {
  75. this.dialogVisible = false
  76. }
  77. },
  78. };
  79. </script>
  80. <style scoped>
  81. * {
  82. box-sizing: border-box;
  83. }
  84. /deep/.el-dialog__body {
  85. padding: 50px 50px 70px 50px;
  86. }
  87. .el-dialog__body .content {
  88. display: flex;
  89. justify-content: space-between;
  90. }
  91. /deep/span {
  92. display: flex;
  93. align-items: center;
  94. }
  95. img{
  96. cursor: pointer;
  97. }
  98. </style>