<link rel="stylesheet" href="/plugins/addon/ticket_internal_premium/template/admin/css/ticket_time.css" />
<!-- =======内容区域======= -->

<div id="content" class="template" v-cloak>
  <com-config>
    <t-card class="list-card-container">
      <ul class="common-tab">
        <li v-permission="'auth_addon_ticket_internal_premium_ticket_list'">
          <a href="index.htm">{{lang.inside_work_order}}</a>
        </li>
        <li v-permission="'auth_addon_ticket_internal_premium_config'">
          <a href="ticket_setting.htm">{{lang.order__configuration}}</a>
        </li>
        <li class="active">
          <a>{{lang.order_text142}}</a>
        </li>
        <li v-permission="'auth_addon_ticket_internal_premium_statistics'">
          <a href="ticket_statistics.htm">{{lang.order_text88}}</a>
        </li>
      </ul>
      <div class="conten-box">
        <div class="add-box">
          <t-button @click="handelAdd"
            v-permission="'auth_addon_ticket_internal_premium_cron_create'">{{lang.order_text154}}</t-button>
        </div>
        <t-table :data="dataList" :columns="columns" hover :loading="dataLoading" row-key="id" size="small">
          <template #cycle_period="{row}">
            <span v-if="row.cycle_period">{{row.cycle_period}}{{cycleObj[row.unit]}}</span>
            <span v-else>{{lang.order_text158}}</span>
          </template>
          <template #admin_name="{row}">
            <span>{{row.admin_name || '--'}}</span>
          </template>
          <template #create_admin_name="{row}">
            <span>{{row.create_admin_name || '--'}}</span>
          </template>
          <template #status="{row}">
            <t-switch size="large" v-model="row.status" :custom-value="[1,0]" @change="(val)=>onChange(row)"
              :disabled="!$checkPermission('auth_addon_ticket_internal_premium_cron_on_off')"></t-switch>
          </template>
          <template #department_name="{row}">
            <span>{{row.department_name || '--'}} - {{row.type_name || '--'}}</span>
          </template>
          <template #start_time="{row}">
            <span>{{row.start_time | formatDate}} - {{row.end_time | formatDate}}</span>
          </template>
          <template #next_create_time="{row}">
            <span>{{row.next_create_time | formatTime}}</span>
          </template>
          <template #op="{row}">
            <t-icon class="btn-icon" name="edit-1" style="margin-right: 10px;" @click="handelEdit(row)"
              v-permission="'auth_addon_ticket_internal_premium_cron_update'">
            </t-icon>
            <t-icon class="btn-icon" name="delete" @click="handelDel(row.id)"
              v-permission="'auth_addon_ticket_internal_premium_cron_delete'">
            </t-icon>
          </template>
        </t-table>
        <t-pagination show-jumper v-if="total" :total="total" :page-size="params.limit" :current="params.page"
          :page-size-options="pageSizeOptions" @change="changePage">
        </t-pagination>
      </div>

      <t-dialog width="950px" :header="formData.id ? lang.order_text164 : lang.order_text154" :footer="false"
        :visible.sync="editVisible" destroy-on-close :close-btn="false">
        <t-form reset-type="initial" label-align="top" :data="formData" :rules="rules" ref="departdForm"
          @submit="formSubmit">
          <div class="flex-item">
            <t-form-item :label="lang.order_text146" name="title">
              <t-input :placeholder="lang.order_text146" v-model="formData.title"></t-input>
            </t-form-item>
            <t-form-item :label="lang.order_text147" name="cycle_period">
              <t-input-number style="width: 100%;" :placeholder="lang.order_text147" v-model="formData.cycle_period"
                theme="normal" :min="1">
              </t-input-number>
            </t-form-item>
            <t-form-item :label="lang.order_text155" name="type_id">
              <t-select v-model="formData.unit" :placeholder="lang.order_text155" :options="typeOption"></t-select>
            </t-form-item>
            <t-form-item :label="lang.order_text150" name="type_id">
              <t-tree-select v-model="formData.type_id" :data="departmentList" clearable
                :placeholder="lang.order_text150" clearable :tree-props="{ expandAll: true, valueMode: 'onlyLeaf' }">
              </t-tree-select>
            </t-form-item>
          </div>
          <div class="flex-item">
            <t-form-item :label="lang.order_text148" name="start_time">
              <t-date-range-picker :disable-date="{before:nowTime}" style="width: 100%;" v-model="range"
                value-type='time-stamp' :presets="presets" clearable>
              </t-date-range-picker>
            </t-form-item>
            <t-form-item :label="lang.order_text157" name="trigger_time">
              <t-time-picker v-model="formData.trigger_time" format="HH:mm" style="width: 100%;"></t-time-picker>
            </t-form-item>
            <t-form-item :label="lang.order_text151" name="admin_id">
              <t-select v-model="formData.admin_id" :placeholder="lang.order_text151" :options="calcAdminList"
                :keys="{ label: 'name', value: 'id' }">
              </t-select>
            </t-form-item>
          </div>

          <t-form-item :label="lang.order_text156">
            <div class="input-box">
              <com-tinymce ref="comTinymce" id="recover"></com-tinymce>
            </div>
          </t-form-item>
          <t-form-item class="turn-inside-dialog-footer">
            <t-button style="margin-right: 16px;" theme="primary" type="submit"
              :loading="submitLoading">{{lang.hold}}</t-button>
            <t-button theme="default" @click="editDiaClose">{{lang.cancel}}</t-button>
          </t-form-item>
        </t-form>
      </t-dialog>
      <t-dialog :visible.sync="delVisible" :header="lang.order_text123" :confirm-btn="lang.order_text32"
        :cancel-btn="lang.order_text33" @confirm="handelDelete" @close="delVisible = false">
      </t-dialog>
    </t-card>
  </com-config>
</div>

<script src="/plugins/addon/ticket_internal_premium/template/admin/js/lang.js"></script>
<script src="/plugins/addon/ticket_internal_premium/template/admin/api/order.js"></script>
<script src="/tinymce/tinymce.min.js"></script>
<script src="/{$template_catalog}/template/{$themes}/components/comTinymce/comTinymce.js"></script>
<script src="/plugins/addon/ticket_internal_premium/template/admin/js/ticket_time.js"></script>