Browse Source

feat: support copying programs and schedules

Casper Dai 3 years ago
parent
commit
69f671e5d9

+ 8 - 0
src/api/calendar.js

@@ -138,3 +138,11 @@ export function rejectSchedule ({ id, name }, remark) {
     data: { remark }
   }, name)
 }
+
+export function copySchedule ({ id }, name) {
+  return messageSend({
+    url: '/content/calendar/copy',
+    method: 'POST',
+    data: { id, name }
+  }, '复制')
+}

+ 11 - 1
src/api/program.js

@@ -5,7 +5,8 @@ import {
   del,
   submit,
   resolve,
-  reject
+  reject,
+  messageSend
 } from './base'
 
 export function getPrograms (query) {
@@ -92,6 +93,7 @@ export function resolveProgram ({ id, name }) {
     params: { id }
   }, name)
 }
+
 export function rejectProgram ({ id, name }, reason) {
   return reject({
     url: '/item/reject',
@@ -100,3 +102,11 @@ export function rejectProgram ({ id, name }, reason) {
     data: { reason }
   }, name)
 }
+
+export function copyProgram ({ id }, name) {
+  return messageSend({
+    url: '/item/copy',
+    method: 'POST',
+    data: { id, name }
+  }, '复制')
+}

+ 11 - 0
src/icons/svg/copy.svg

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 24.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 viewBox="0 0 30 30" style="enable-background:new 0 0 30 30;" xml:space="preserve">
+<g>
+	<path d="M24.4,8.2H16l-4.6,4.6v12.4c0,1.6,1.3,3,3,3h10c1.7,0,3-1.4,3-3v-14C27.4,9.6,26.1,8.2,24.4,8.2z M16.4,10.6v2.6h-2.6
+		L16.4,10.6z M25.4,25.2c0,0.5-0.5,1-1,1h-10c-0.5,0-1-0.5-1-1v-10h5v-5h6c0.5,0,1,0.5,1,1V25.2z"/>
+	<path d="M16.4,2.2H8L3.4,6.8v12.4c0,1.6,1.3,3,3,3h3v-2h-3c-0.5,0-1-0.5-1-1v-10h5v-5h6c0.5,0,1,0.5,1,1v1h2v-1
+		C19.4,3.6,18.1,2.2,16.4,2.2z M8.4,7.2H5.8l2.6-2.6V7.2z"/>
+</g>
+</svg>

+ 9 - 0
src/scss/bem/_component.scss

@@ -12,6 +12,11 @@
     width: 80%;
   }
 
+  &.mini {
+    max-width: 600px;
+    min-height: auto;
+  }
+
   &.hidden-footer {
     .el-dialog__body {
       padding-bottom: $spacing;
@@ -159,6 +164,10 @@
       width: 180px;
     }
 
+    &.auto {
+      width: auto;
+    }
+
     &.required::before {
       content: '*';
       color: #ff0000;

+ 77 - 5
src/views/bigscreen/index.vue

@@ -9,7 +9,7 @@
       <div class="l-flex__auto l-flex--row c-sibling-item">
         <button
           class="o-button"
-          @click="toAdd"
+          @click="onAdd"
         >
           <i class="o-button__icon el-icon-circle-plus-outline" />
           新增
@@ -95,6 +95,17 @@
                 @click.stop="onSubmit(item)"
               />
             </el-tooltip>
+            <el-tooltip
+              v-if="item.status === 2"
+              content="复制"
+              :hide-after="2000"
+            >
+              <svg-icon
+                class="o-icon--active u-pointer"
+                icon-class="copy"
+                @click.stop="onCopy(item)"
+              />
+            </el-tooltip>
             <permission
               :skip="item.status === 0"
               :access="Access.DELETE_FORCE"
@@ -178,6 +189,40 @@
         </button>
       </template>
     </el-dialog>
+    <el-dialog
+      title="复制节目"
+      :visible.sync="copying"
+      custom-class="c-dialog mini"
+      :close-on-click-modal="false"
+      :before-close="onCloseCopyDialog"
+    >
+      <div class="c-form">
+        <div class="c-form__section">
+          <span class="c-form__label auto">名称:</span>
+          <el-input
+            v-model.trim="copyProgram.name"
+            class="c-form__item"
+            placeholder="请输入名称"
+            maxlength="50"
+            show-word-limit
+          />
+        </div>
+      </div>
+      <template #footer>
+        <button
+          class="o-button"
+          @click="copy"
+        >
+          确定
+        </button>
+        <button
+          class="o-button cancel"
+          @click="onCloseCopyDialog"
+        >
+          取消
+        </button>
+      </template>
+    </el-dialog>
   </wrapper>
 </template>
 
@@ -190,7 +235,8 @@ import {
   updateProgramName,
   deleteProgram,
   getProgram,
-  submitProgram
+  submitProgram,
+  copyProgram
 } from '@/api/program'
 import { State } from '@/constant'
 import { createListOptions } from '@/utils'
@@ -215,7 +261,12 @@ export default {
         status: void 0,
         resolutionRatio: void 0,
         name: ''
-      })
+      }),
+      copying: false,
+      copyProgram: {
+        id: null,
+        name: ''
+      }
     }
   },
   computed: {
@@ -309,7 +360,7 @@ export default {
         })
       }
     },
-    toAdd () {
+    onAdd () {
       this.program = {
         name: '',
         resolutionRatio: ''
@@ -409,6 +460,27 @@ export default {
         }
         this.getList()
       })
+    },
+    onCopy ({ id, name }) {
+      this.copyProgram = { id, name }
+      this.copying = true
+    },
+    copy () {
+      const { id, name } = this.copyProgram
+      copyProgram({ id }, name).then(() => {
+        this.onCloseCopyDialog()
+        const params = this.params
+        if (params.status !== void 0 && params.status !== State.READY) {
+          params.status = void 0
+        }
+        if (params.name && !(new RegExp(params.name).test(name))) {
+          params.name = ''
+        }
+        this.search()
+      })
+    },
+    onCloseCopyDialog () {
+      this.copying = false
     }
   }
 }
@@ -460,7 +532,7 @@ export default {
       rgba(#000, 0.6) 100%
     );
 
-    i {
+    .o-icon--active {
       margin-left: $spacing;
       font-size: 18px;
     }

+ 63 - 2
src/views/schedule/index.vue

@@ -218,6 +218,40 @@
         :schedule="scheduleId"
       />
     </el-dialog>
+    <el-dialog
+      title="复制"
+      :visible.sync="copying"
+      custom-class="c-dialog mini"
+      :close-on-click-modal="false"
+      :before-close="onCloseCopyDialog"
+    >
+      <div class="c-form">
+        <div class="c-form__section">
+          <span class="c-form__label auto">名称:</span>
+          <el-input
+            v-model.trim="copySchedule.name"
+            class="c-form__item"
+            placeholder="请输入名称"
+            maxlength="50"
+            show-word-limit
+          />
+        </div>
+      </div>
+      <template #footer>
+        <button
+          class="o-button"
+          @click="copy"
+        >
+          确定
+        </button>
+        <button
+          class="o-button cancel"
+          @click="onCloseCopyDialog"
+        >
+          取消
+        </button>
+      </template>
+    </el-dialog>
   </wrapper>
 </template>
 
@@ -227,7 +261,8 @@ import {
   getSchedules,
   addSchedule,
   deleteSchedule,
-  submitSchedule
+  submitSchedule,
+  copySchedule
 } from '@/api/calendar'
 import { State } from '@/constant'
 import { createListOptions } from '@/utils'
@@ -253,7 +288,12 @@ export default {
       scheduleId: null,
       fetching: false,
       ratios: [],
-      isPreviewing: false
+      isPreviewing: false,
+      copying: false,
+      copySchedule: {
+        id: null,
+        name: ''
+      }
     }
   },
   computed: {
@@ -376,6 +416,27 @@ export default {
         }
         this.getList()
       })
+    },
+    onCopy ({ id, name }) {
+      this.copySchedule = { id, name }
+      this.copying = true
+    },
+    copy () {
+      const { id, name } = this.copySchedule
+      copySchedule({ id }, name).then(() => {
+        this.onCloseCopyDialog()
+        const params = this.options.params
+        if (params.status !== void 0 && params.status !== State.READY) {
+          params.status = void 0
+        }
+        if (params.name && !(new RegExp(params.name).test(name))) {
+          params.name = ''
+        }
+        this.search()
+      })
+    },
+    onCloseCopyDialog () {
+      this.copying = false
     }
   }
 }