123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681 |
- {extend name="common/common2" /}
- {block name="main"}
- <div class="row">
- <div class="col-sm-12">
- <div class="ibox float-e-margins">
- <!--<div class="ibox-title">-->
- <!--<h5>{$title}</h5>-->
- <!--<div class="ibox-tools">-->
- <!--<a class="toback" href="{:url('index')}">-->
- <!--返回上一页-->
- <!--</a>-->
- <!--</div>-->
- <!--</div>-->
- <div class="ibox-content">
- <div id="vueapp">
- <div style="overflow: auto;padding: 15px 20px;">
- <el-form ref="form" :model="form" :rules="rules" label-width="100px">
- <el-form-item label="名称" prop="name">
- <el-input v-model="form.name" maxlength="50" show-word-limit placeholder="请输入" />
- </el-form-item>
- <el-form-item label="参与考勤人员" prop="selectUser">
- <el-select
- v-model="selectUser"
- placeholder="请选择"
- multiple
- collapse-tags
- filterable
- >
- <el-option
- v-for="item in users"
- :key="item.id"
- :label="item.real_name"
- :value="item.id">
- </el-option>
- <!-- <el-option-group-->
- <!-- v-for="group in users"-->
- <!-- :key="group.name"-->
- <!-- :label="group.name"-->
- <!-- >-->
- <!-- <el-option-->
- <!-- v-for="item in group.sub"-->
- <!-- :key="item.USER_ID"-->
- <!-- :label="item.REAL_NAME"-->
- <!-- :value="item.USER_ID">-->
- <!-- </el-option>-->
- <!-- </el-option-group>-->
- </el-select>
- </el-form-item>
- <el-form-item label="类型" prop="type">
- <el-radio v-if="info" v-model="form.type" disabled label="1">
- 固定班制
- </el-radio>
- <el-radio v-if="info" v-model="form.type" disabled label="2">
- 排班制
- </el-radio>
- <el-radio v-if="!info" v-model="form.type" label="1">
- 固定班制
- </el-radio>
- <el-radio v-if="!info" v-model="form.type" label="2">
- 排班制
- </el-radio>
- </el-form-item>
- <el-form-item v-if="Number(form.type) === 2" label="考勤班次">
- <el-select
- v-if="classload"
- v-model="checkClass"
- multiple
- placeholder="请选择"
- style="width:100%;"
- @change="changePbClass"
- >
- <el-option
- v-for="item in classes"
- :key="item.id"
- :label="item.name"
- :value="item.id.toString()"
- />
- </el-select>
- </el-form-item>
- <el-form-item v-if="Number(form.type) === 2 && checkClass.length" label="排班周期">
- <table border="0" style="width:100%;">
- <tr>
- <th>周期名称</th>
- <th>周期天数</th>
- <th>操作</th>
- </tr>
- <tr v-for="item in [circle]">
- <td>{{item.title}}</td>
- <td>{{item.days}}</td>
- <td>
- <el-link type="primary" :underline="false" @click="setCircle()">
- 设置排班周期
- </el-link>
- </td>
- </tr>
- </table>
- </el-form-item>
- <el-form-item v-if="Number(form.type) === 1" label="工作日设置">
- <table border="0" style="width:100%;text-align: center;">
- <tr>
- <th style="width:120px">工作日</th>
- <th>班次时间段</th>
- </tr>
- <tr v-for="item in tableData">
- <td>{{item.text}}</td>
- <td>
- <el-select v-if="classload" v-model="item.class_id" size="small" clearable placeholder="请选择" style="width:100%">
- <el-option
- v-for="item in classes"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- </td>
- </tr>
- </table>
- </el-form-item>
- <el-form-item v-if="Number(form.type) === 1" label="特殊日期" >
- <div>
- <el-button size="small" @click="handleClass(1,null)">
- 添加
- </el-button> <span> 必须打卡的日期</span>
- </div>
- <table v-if="signTable.length > 0" border="0" style="width:100%;">
- <tr>
- <th>日期</th>
- <th>考勤时间</th>
- <th>操作</th>
- </tr>
- <tr v-for="item in signTable" >
- <td>{{item.day}}</td>
- <td>
- {{item.class_name}}
- </td>
- <td>
- <el-link type="primary" :underline="false" @click="handleClass(1, item)">
- 编辑
- </el-link>
- <el-link type="danger" :underline="false" @click="delClass(1,item)">
- 删除
- </el-link>
- </td>
- </tr>
- </table>
- <div>
- <el-button size="small" @click="handleClass(2,null)">
- 添加
- </el-button> <span> 不用打卡的日期</span>
- </div>
- <table v-if="unsignTable.length > 0" border="0" style="width:100%;">
- <tr>
- <th>日期</th>
- <th>考勤时间</th>
- <th>操作</th>
- </tr>
- <tr v-for="item in unsignTable">
- <td>{{item.day}}</td>
- <td>
- 休息
- </td>
- <td>
- <el-link type="danger" :underline="false" @click="changeClass(item)">
- 删除
- </el-link>
- </td>
- </tr>
- </table>
- </el-form-item>
- <el-form-item label="考勤方式">
- <el-checkbox-group v-model="checkWay">
- <el-checkbox label="1" >
- 地点打卡
- </el-checkbox>
- <el-checkbox label="2">
- 考勤机打卡
- </el-checkbox>
- </el-checkbox-group>
- <!-- <span class="text-danger">物业人员仅支持考勤机打卡</span>-->
- </el-form-item>
- <el-form-item label="考勤地点">
- <el-select
- v-if="addrload"
- v-model="checkAddr"
- multiple
- collapse-tags
- placeholder="请选择"
- >
- <el-option
- v-for="item in addr"
- :key="item.id"
- :label="item.title"
- :value="item.id.toString()"
- />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" :loading="flag" @click="submitbtn('form')">
- 确定
- </el-button>
- </el-form-item>
- </el-form>
- </div>
- <el-dialog
- v-if="classVisible"
- :title="title1"
- :visible.sync="classVisible"
- width="600px"
- @close="handleCancelModal"
- >
- <el-form ref="classForm" :model="classForm" :rules="rules" label-position="right" label-width="120px">
- <el-form-item label="日期">
- <el-date-picker
- v-model="classForm.day"
- type="date"
- placeholder="请选择日期"
- :editable="false"
- value-format="yyyy-MM-dd"
- :clearable="true"
- @change="changeDate(classForm.type,classForm.edit)"
- />
- <div class="text-danger">
- {{ errormsg }}
- </div>
- </el-form-item>
- <el-form-item v-if="classForm.type === 1" label="考勤班次">
- <el-select v-if="classload" v-model="classForm.class_id" clearable placeholder="请选择">
- <el-option
- v-for="item in classes"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- </el-form-item>
- <!-- <span slot="footer" class="dialog-footer">-->
- <el-button type="primary" style="margin-left: 200px" @click="handleClassForm('classForm')">确 定</el-button>
- </span>
- </el-form>
- </el-dialog>
- <el-dialog
- v-if="circleVisible"
- title="设置排班周期"
- :visible.sync="circleVisible"
- width="600px"
- @close="handleCancelModal2"
- >
- <el-form v-if="circle" ref="circleForm" :model="circle" :rules="rules" label-position="right" label-width="120px">
- <el-form-item label="周期名称">
- <el-input v-model="circle.title" maxlength="10" show-word-limit placeholder="请输入名称" />
- </el-form-item>
- <el-form-item label="周期天数">
- <el-input-number v-model="circle.days" :min="2" :max="31" :step="1" @change="changeDays" />
- </el-form-item>
- <el-form-item v-if="circle.class.length > 0" label="周期排班">
- <div v-for="item in circle.class" :key="item.id">
- <span>第{{ item.id }}天: </span>
- <span v-if="selectClasses.length > 0">
- <el-select v-model="item.class_id" size="small" clearable placeholder="请选择(不选即为休息)">
- <el-option
- v-for="item2 in selectClasses"
- :key="item2.id"
- :label="item2.name"
- :value="item2.id"
- />
- </el-select>
- </span>
- </div>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="handleCancelModal2">取 消</el-button>
- <el-button type="primary" @click="handleCircleForm('circleForm')">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </div>
- </div>
- </div>
- </div>
- {/block}
- {block name="script"}
- <script>
- $(document).ready(function(){
- formSetValue("type", {$info.type|default=1});
- });
- </script>
- <script>
- var users = <?=json_encode($users)?>;
- var classes = <?=json_encode($classes)?>;
- var addrs = <?=json_encode($addrs)?>;
- var info = <?=json_encode($info)?>;
- console.log(info);
- new Vue({
- el: '#vueapp',
- data: function() {
- return {
- form : {
- id: 0,
- name: '',
- type: '1',
- },
- rules : {
- name: [
- { required: true, message: '请输入名称', trigger: 'blur' },
- ],
- },
- selectUser: [],
- users: users, // 所有用户
- checkClass:[], // 选择的考勤班次
- classload:true,
- // info: null,
- info: info?info:null,
- flag: false,
- tableData:[
- {
- week: 1, text: '周一', class_id: '', class_name: '',
- },
- {
- week: 2, text: '周二', class_id: '', class_name: '',
- },
- {
- week: 3, text: '周三', class_id: '', class_name: '',
- },
- {
- week: 4, text: '周四', class_id: '', class_name: '',
- },
- {
- week: 5, text: '周五', class_id: '', class_name: '',
- },
- {
- week: 6, text: '周六', class_id: '', class_name: '',
- },
- {
- week: 0, text: '周日', class_id: '', class_name: '',
- },
- ],
- signTable : [],
- unsignTable : [],
- circle : {
- title: '',
- days: 0,
- class: [
- {
- id: 1,
- class_id: '',
- },
- {
- id: 2,
- class_id: '',
- },
- ],
- },
- checkWay:['1', '2'],
- circleVisible:false,
- selectClasses : [],
- checkAddr:[],
- addr:addrs,
- addrload:true,
- classes:classes,
- title1: '必须打卡日期',
- errormsg:'',
- classForm:{
- day: '',
- class_id: '',
- type: 1,
- edit: 0,
- },
- oldday : '', // 编辑用
- classVisible:false,
- dataload:true,
- }
- },
- watch: {
- },
- created(){
- if(info){
- this.form = {
- id: info.id,
- name: info.name,
- type: info.type.toString(),
- };
- this.selectUser = info.userIds;
- this.users = users; // 所有用户
- this.checkClass = info.class_id?info.class_id.split(','):[]; // 选择的考勤班次
- this.checkAddr = info.addr?info.addr.split(','):[];
- this.addr = addrs;
- this.classes = classes;
- const content = JSON.parse(this.info.content);
- const way = this.info.cate ? this.info.cate.split(',') : [];
- this.checkWay = way ;
- const classs = this.info.classId ? this.info.classId.split(',') : [];
- classs.forEach((item) => {
- this.checkClass.push(item.toString());
- });
- if (this.info.type === 1) {
- this.tableData = content.week;
- this.signTable = content.sign;
- this.unsignTable = content.unsign;
- } else {
- this.circle = content.circle;
- this.selectClasses = [];
- this.classes.forEach((item) => {
- if (this.checkClass.includes(item.id.toString())) {
- this.selectClasses.push(item);
- }
- });
- }
- }
- },
- methods: {
- changePbClass() {
- this.selectClasses = [];
- this.classes.forEach((item) => {
- if (this.checkClass.includes(item.id.toString())) {
- this.selectClasses.push(item);
- }
- });
- this.circle = {
- title: '',
- days: 2,
- class: [
- {
- id: 1,
- class_id: '',
- },
- {
- id: 2,
- class_id: '',
- },
- ],
- };
- },
- handleClass(type, obj) {
- this.oldday = '';
- if (obj) {
- this.classForm = {
- day: obj.day,
- class_id: obj.class_id,
- type,
- edit: 1,
- };
- this.oldday = obj.day;
- } else {
- this.classForm = {
- day: '',
- class_id: '',
- type,
- edit: 0,
- };
- }
- if (type === 1) {
- this.title1 = '必须打卡的日期';
- } else {
- this.title1 = '不用打卡的日期';
- }
- this.classVisible = true;
- },
- delClass(type,obj){
- if (type === 1) {
- this.signTable = this.signTable.filter(item => item.day !== obj.day);
- } else {
- this.unsignTable = this.unsignTable.filter(item => item.day !== obj.day);
- }
- },
- changeClass(obj){
- this.unsignTable = this.unsignTable.filter(item => item.day !== obj.day);
- },
- handleCancelModal() {
- this.classVisible = false;
- },
- handleClassForm(formName) { // eslint-disable-line
- console.log(formName, this.classForm);
- if (this.errormsg) {
- return false;
- }
- if (!this.classForm.day) {
- this.$message.error('未选择日期');
- return false;
- } if (this.classForm.type === 1 && !this.classForm.class_id) {
- this.$message.error('未选择班次');
- return false;
- }
- if (this.classForm.type === 1) {
- let ff = false;
- this.signTable.forEach((item) => {
- const info = item;
- if (item.day === this.oldday && this.classForm.edit) { // 编辑
- info.class_id = this.classForm.class_id;
- info.day = this.classForm.day;
- ff = true;
- }
- });
- if (!ff) {
- this.signTable.push({
- day: this.classForm.day,
- class_id: this.classForm.class_id,
- class_name: '',
- });
- }
- this.signTable.forEach((item) => {
- const info = item;
- this.classes.forEach((item2) => {
- if (item2.id === info.class_id) {
- info.class_name = item2.name;
- }
- });
- });
- const nsignTable = JSON.parse(JSON.stringify(this.signTable));
- this.signTable = [];
- this.signTable = JSON.parse(JSON.stringify(nsignTable));
- } else {
- this.unsignTable.push({
- day: this.classForm.day,
- });
- const nunsignTable = JSON.parse(JSON.stringify(this.unsignTable));
- this.unsignTable = [];
- this.unsignTable = JSON.parse(JSON.stringify(nunsignTable));
- }
- console.log(this.signTable, this.unsignTable);
- this.classVisible = false;
- },
- goBack() {
- this.$router.go(-1);
- },
- changeDate(type, edit) {
- this.errormsg = '';
- if (this.classForm.day) {
- if(edit === 1){ // eslint-disable-line
- if (type === 1) {
- this.unsignTable.forEach((item) => {
- if (item.day === this.classForm.day) {
- this.errormsg = '该日期已被指定为不需要打卡';
- }
- });
- } else {
- this.signTable.forEach((item) => {
- if (item.day === this.classForm.day) {
- this.errormsg = '该日期已被指定为必须打卡';
- }
- });
- }
- } else {
- this.signTable.forEach((item) => {if (item.day === this.classForm.day) {
- this.errormsg = '该日期已被指定为必须打卡';
- }
- });
- this.unsignTable.forEach((item) => {
- if (item.day === this.classForm.day) {
- this.errormsg = '该日期已被指定为不需要打卡';
- }
- });
- }
- } else {
- this.errormsg = '';
- }
- },
- setCircle() {
- console.log('sss',this.selectClasses,this.checkClass);
- this.circleVisible = true;
- },
- handleCircleForm() {
- this.circleVisible = false;
- },
- handleCancelModal2() {
- this.circleVisible = false;
- },
- changeDays() {
- console.log('circle', this.circle);
- const newclass = [];
- for(let i=1;i<=this.circle.days;i++){ // eslint-disable-line
- newclass.push({
- id: i,
- class_id: '',
- });
- }
- newclass.forEach((item) => {
- const info = item;
- this.circle.class.forEach((item2) => {
- if (item.id === item2.id) {
- info.class_id = item2.class_id;
- }
- });
- });
- this.circle.class = [];
- this.circle.class = JSON.parse(JSON.stringify(newclass));
- },
- submitbtn(formName){
- this.$refs[formName].validate((valid) => { // eslint-disable-line
- if (valid) {
- this.flag = true;
- let content = {};
- if (Number(this.form.type) === 1) {
- content = {
- week: this.tableData,
- sign: this.signTable,
- unsign: this.unsignTable,
- };
- } else {
- content = {
- circle: this.circle,
- };
- }
- let param = {
- id: this.form.id,
- name: this.form.name,
- type: this.form.type,
- cate: this.checkWay ? this.checkWay.join(',') : '',
- classId: this.checkClass.length > 0 ? this.checkClass.join(',') : '',
- addr: this.checkAddr.length > 0 ? this.checkAddr.join(',') : '',
- content: JSON.stringify(content),
- users: this.selectUser.join(','),
- };
- let that = this;
- $.ajax({
- url: 'add',
- type: 'POST',
- data: param,
- success: function(data){
- if(data.code == '1'){
- layer.msg('操作成功',{time:2000})
- parent.layer.closeAll();
- // window.location.href = "{:url('AttendanceGroup/index')}"
- // parent.window.location.reload();
- }else{
- layer.msg('操作失败')
- }
- that.flag = false;
- },
- error: function (){
- that.flag = false;
- }
- });
- }
- });
- }
- }
- })
- </script>
- {/block}
|