123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995 |
- <template>
- <div class="temp_task_box">
- <van-nav-bar :title="title" left-text="返回" @click-left="$route_back" left-arrow><van-icon @click="flexDialog=true" slot="right" name="question-o" style="color:#fff;" /></van-nav-bar>
- <div class="body_com">
- <scroller :isNeed="isNeed">
- <van-cell-group>
- <van-cell>
- <Mtextarea
- v-model="data.task_name"
- placeholder="请输入关于任务内容"
- required
- v-validate="'required|max:20'"
- name="任务内容"
- :text_max="20"
- :imgs_max="3"
- images
- :imgs.sync="data.file_list"
- />
- </van-cell>
- </van-cell-group>
- <van-cell-group class="point-field">
- <van-cell title="积分类型" required>
- <template slot="right-icon">
- <van-radio-group v-model="data.pt_id" direction="horizontal" class="radio_button">
- <van-radio class="list" :class="{ changeRadio: item.id === data.pt_id }" v-if="item.code !== 'JX'" :name="item.id" v-for="(item, index) in pts" :key="index">
- {{ item.name }}
- </van-radio>
- </van-radio-group>
- <!-- <smallTip icon="question-o" position="30%">-->
- <!-- <p style="margin: 0; line-height: 0.6rem">A分:物质分,与钱直接挂钩</p>-->
- <!-- <p style="margin: 0; line-height: 0.6rem">B分:福利分,与福利待遇挂钩</p>-->
- <!-- <p style="margin: 0; line-height: 0.6rem">绩效分:工作分,与绩效考核挂钩</p>-->
- <!-- </smallTip>-->
- </template>
- </van-cell>
- <van-cell title="指定规则">
- <template slot="right-icon">
- <van-radio-group
- v-model="data.rule_type"
- direction="horizontal"
- class="radio_button"
- >
- <van-radio class="list" :name="0" >
- <span class="rule_type_span">不指定</span>
- </van-radio>
- <van-radio class="list" :name="1" >
- <span class="rule_type_span">分类</span>
- </van-radio>
- <van-radio class="list" :name="2" >
- <span class="rule_type_span">规则</span>
- </van-radio>
- </van-radio-group>
- </template>
- </van-cell>
- <!-- 选择分类 -->
- <CategorySelectorCell
- v-if="data.rule_type === 1"
- title="细则分类"
- v-model="rules"
- required
- :pt-id="data.pt_id"
- :multi="false"
- scope
- />
- <!--选择规则 -->
- <van-cell
- v-if="data.rule_type === 2"
- title="积分规则"
- @click="showRuleSelector = true"
- required
- :value="rule_items.length <= 0 ? '' : `已选${rule_items.length}条`"
- />
- <RuleScopeSelector :visible.sync = showRuleSelector :selected="rule_items" @confirm="selected => rule_items = selected" :pt-id="data.pt_id" />
- <!-- <RuleCategorySelectorCell-->
- <!-- v-if="data.rule_type === 2"-->
- <!-- :pt-id="data.pt_id"-->
- <!-- required-->
- <!-- name="请选择积分规则"-->
- <!-- title="积分规则"-->
- <!-- v-model="rule_items"-->
- <!-- scope-->
- <!-- :multi="false"-->
- <!-- >-->
- <!-- <template slot="label">-->
- <!-- <span style="color: red">{{ruleItemLabel}}</span>-->
- <!-- </template>-->
- <!-- </RuleCategorySelectorCell>-->
- <van-cell title="任务积分" style="padding:0 0.32rem; padding-top:0.16rem;" :border="false" required />
- <NumberInput v-model="data.base_point" v-validate="'required'" :min="minPoint" :max="maxPoint"/>
- </van-cell-group>
- <van-cell-group>
- <EmployeeSelectorCell
- title="审批人"
- name="审批人"
- iconType="records"
- required
- v-validate="'required'"
- :show_manager_only="true"
- v-model="reviewer"
- :multi="false"
- ></EmployeeSelectorCell>
- <van-cell title="重复周期" @click="show_task_cycle_popup = true">
- <template>
- <span v-if="data.task_cycle == 0">不重复</span>
- <span v-if="data.task_cycle == 1">每天重复</span>
- <span v-if="data.task_cycle == 2">每周重复</span>
- <span v-if="data.task_cycle == 3">每月重复</span>
- </template>
- </van-cell>
- <DateTimeCell title="截止时间" required v-validate="'required'" name="截止时间" v-if="data.task_cycle == 0" v-model="data.expire_time"></DateTimeCell>
- <van-cell :value="'每天' + task_expire_day_text" is-link @click="show_task_expire_day = true" title="截止时间" v-if="data.task_cycle == 1" />
- <van-cell :value="'每' + task_expire_day_text" is-link @click="show_task_expire_day = true" title="截止时间" v-if="data.task_cycle == 2" />
- <van-cell :value="'每月' + task_expire_day_text" is-link @click="show_task_expire_day = true" title="截止时间" v-if="data.task_cycle == 3" />
- <van-cell title="有效日期" v-if="data.task_cycle !== 0" @click="showScheduleExpireDate = true" :value="data.schedule_expire_date" :center="true">
- <template #right-icon >
- <van-icon color="#A4A5A7" name="arrow" v-if="!data.schedule_expire_date" />
- <van-icon color="#A4A5A7" name="close" v-else @click.stop="clearScheduleExpireDate" style="margin-left: 10px" />
- </template>
- </van-cell>
- <van-field v-model="data.ahead_award_point" type="digit">
- <template slot="label">
- <div class="flex-box-ce">
- <span>提前奖分(天)</span>
- <span class="flex-1 red" style="text-align: right;">+</span>
- </div>
- </template>
- </van-field>
- <van-field v-model="data.ahead_award_point_limit" type="digit" label="奖分上限">
- <template slot="label">
- <div class="flex-box-ce">
- <span>奖分上限</span>
- <span class="flex-1 red" style="text-align: right;">+</span>
- </div>
- </template>
- </van-field>
- <van-field v-model="data.timeout_deduction_point" type="digit" label="逾期扣分(天)">
- <template slot="label">
- <div class="flex-box-ce">
- <span>逾期扣分(天)</span>
- <span class="flex-1 green" style="text-align: right;">-</span>
- </div>
- </template>
- </van-field>
- <van-field v-model="data.timeout_deduction_point_limit" type="digit" label="扣分上限">
- <template slot="label">
- <div class="flex-box-ce">
- <span>扣分上限</span>
- <span class="flex-1 green" style="text-align: right;">-</span>
- </div>
- </template>
- </van-field>
- </van-cell-group>
- <van-cell-group :border="false">
- <van-cell icon="records" v-if="show_task_remark" title="任务备注" :label="data.task_remark" @click="show_task_remark_popup = true">
- <template slot="right-icon">
- <van-icon name="close" @click.stop="del_task_remark" />
- </template>
- </van-cell>
- <van-cell class="depts_cell" icon="eye-o" v-if="show_task_super_satisfied" title="可见范围" @click="show_task_super_satisfied_popup = true">
- <template slot="right-icon">
- <van-icon name="close" @click.stop="del_task_super_satisfied" />
- </template>
- <template slot="label">
- <div style="display: inline;" class="employee_cell_value" v-if="depts.length <= 2">
- <span v-for="(item, index) in depts" :key="index">
- <em v-show="index > 0">,</em>
- {{ item.dept_name }}
- </span>
- </div>
- <div style="display: inline;" class="employee_cell_value" v-if="depts.length > 2">
- <span v-for="(item, index) in depts" v-if="index < 2" :key="index">
- <em v-show="index > 0">,</em>
- {{ item.dept_name }}
- </span>
- 等{{ depts.length }}个
- </div>
- </template>
- </van-cell>
- </van-cell-group>
- <div style="padding:0.32rem;">
- <van-row gutter="5" class="choose_button">
- <van-col class="list" span="12" v-if="!show_task_remark">
- <van-button @click="show_task_remark_popup = true" type="default" block icon="records">任务备注</van-button>
- </van-col>
- <van-col class="list" span="12" v-if="!show_task_super_satisfied">
- <van-button @click="show_task_super_satisfied_popup = true" type="default" block icon="eye-o">可见范围</van-button>
- </van-col>
- </van-row>
- </div>
- <div style="padding: 0.32rem"><van-button type="info" block @click="sava_btn">提交</van-button></div>
- <div style="height: 1rem;"></div>
- </scroller>
- </div>
- <van-popup v-model="show_task_cycle_popup" position="right" style="height:100%; width:100%;">
- <div :style="'padding-top:' + bar_height + 'px;background-color: #238dfa;'"></div>
- <van-nav-bar
- title="重复周期"
- left-text="返回"
- @click-left="show_task_cycle_popup = false"
- left-arrow
- right-arrow
- @click-right="save_show_task_cycle"
- right-text="保存"
- ></van-nav-bar>
- <div style="padding: 0.2rem 0.32rem 0; font-size: 0.26rem;" class="fontColorC" v-show="data.task_cycle == 0">任务为一次性任务</div>
- <div style="padding: 0.2rem 0.32rem 0; font-size: 0.26rem;" class="fontColorC" v-show="data.task_cycle == 1">任务每天0点自动发布</div>
- <div style="padding: 0.2rem 0.32rem 0; font-size: 0.26rem;" class="fontColorC" v-show="data.task_cycle == 2">任务每周周一自动发布</div>
- <div style="padding: 0.2rem 0.32rem 0; font-size: 0.26rem;" class="fontColorC" v-show="data.task_cycle == 3">任务每月1号自动发布</div>
- <van-radio-group v-model="data.task_cycle">
- <van-cell-group>
- <van-cell title="不重复" clickable @click="data.task_cycle = 0">
- <template slot="right-icon">
- <van-radio :name="0" />
- </template>
- </van-cell>
- <van-cell title="每天重复" clickable @click="data.task_cycle = 1">
- <template slot="right-icon">
- <van-radio :name="1" />
- </template>
- </van-cell>
- <van-cell title="每周重复" clickable @click="data.task_cycle = 2">
- <template slot="right-icon">
- <van-radio :name="2" />
- </template>
- </van-cell>
- <van-cell title="每月重复" clickable @click="data.task_cycle = 3">
- <template slot="right-icon">
- <van-radio :name="3" />
- </template>
- </van-cell>
- </van-cell-group>
- </van-radio-group>
- </van-popup>
- <van-popup v-model="show_task_super_satisfied_popup" position="right" style="height:100%; width:100%;">
- <div :style="'padding-top:' + bar_height + 'px;background-color: #238dfa;'"></div>
- <van-nav-bar
- title="可见范围"
- left-text="返回"
- @click-left="show_task_super_satisfied_popup = false"
- left-arrow
- right-arrow
- @click-right="save_task_super_satisfied"
- right-text="保存"
- ></van-nav-bar>
- <van-cell-group v-if="show_task_super_satisfied_popup"><DeptSelectorCell title="可见范围" v-model="depts"></DeptSelectorCell></van-cell-group>
- </van-popup>
- <van-popup v-model="show_timeout_deduction_point_popup" position="right" style="height:100%; width:100%;">
- <div :style="'padding-top:' + bar_height + 'px;background-color: #238dfa;'"></div>
- <van-nav-bar
- title="逾期扣分"
- left-text="返回"
- @click-left="show_timeout_deduction_point_popup = false"
- left-arrow
- right-arrow
- @click-right="save_timeout_deduction_point"
- right-text="保存"
- ></van-nav-bar>
- <van-cell-group v-if="show_timeout_deduction_point_popup">
- <div class="point_popup_tip red" slot="title">每逾期一天扣多少分</div>
- <van-field type="number" v-model="data.timeout_deduction_point" placeholder="请输入积分" label="扣除分值" />
- </van-cell-group>
- </van-popup>
- <van-dialog v-model="flexDialog" title="" width="350" :show-confirm-button="false" closeOnClickOverlay>
- <div class="flexDiaWb">
- <h3>悬赏任务</h3>
- <p style="color: #3F4755;">公开悬赏任务到某个部门或全公司,员工抢做任务负责人,完成可审批打分,也支持设置自动重复发布</p>
- <div style="text-align: right;padding: 10px 0;" @click="flexDialog=false">我知道了</div>
- </div>
- </van-dialog>
- <van-popup v-model="show_task_remark_popup" position="right" style="height:100%; width:100%;">
- <div :style="'padding-top:' + bar_height + 'px;background-color: #238dfa;'"></div>
- <van-nav-bar title="任务备注" left-text="返回" @click-left="show_task_remark_popup = false" left-arrow right-arrow @click-right="save_remark" right-text="保存"></van-nav-bar>
- <van-cell-group v-if="show_task_remark_popup">
- <van-cell><Mtextarea v-model="data.task_remark" placeholder="请输入关于任务备注" :text_max="100"></Mtextarea></van-cell>
- </van-cell-group>
- </van-popup>
- <van-popup v-model="show_task_expire_day" position="bottom">
- <van-picker
- :columns="columns1"
- :default-index="task_expire_day"
- v-show="data.task_cycle == 1"
- show-toolbar
- @cancel="show_task_expire_day = false"
- @confirm="task_expire_dayonChange"
- />
- <van-picker
- :columns="columns2"
- :default-index="task_expire_day"
- v-show="data.task_cycle == 2"
- show-toolbar
- @cancel="show_task_expire_day = false"
- @confirm="task_expire_dayonChange"
- />
- <van-picker
- :columns="columns3"
- :default-index="task_expire_day"
- v-show="data.task_cycle == 3"
- show-toolbar
- @cancel="show_task_expire_day = false"
- @confirm="task_expire_dayonChange"
- />
- </van-popup>
- <van-calendar
- title="有效日期"
- color="#26A2FF"
- v-model="showScheduleExpireDate"
- :show-confirm="false"
- :default-date="scheduleExpireDate"
- @confirm="scheduleExpireDateConfirm"
- />
- </div>
- </template>
- <script>
- import DeptSelectorCell from '@/components/DeptSelectorCell';
- import DateTimeCell from '@/components/DateTimeCell';
- import RuleCategorySelectorCell from '@/components/RuleCategorySelectorCell1'
- import CategorySelectorCell from '@/components/CategorySelectorCell'
- import NumberInput from '@/components/NumberInput';
- import Vue from 'vue';
- import moment from 'moment'
- import Mtextarea from '@/components/Mtextarea';
- import EmployeeSelectorCell from '@/components/EmployeeSelectorCell';
- import smallTip from '@/components/smallTip';
- import { calendar, Overlay, DatetimePicker, RadioGroup, Radio, Picker } from 'vant';
- import RuleScopeSelector from "../../../components/RuleScopeSelector.vue";
- Vue.use(Radio);
- Vue.use(Picker);
- Vue.use(RadioGroup);
- Vue.use(calendar)
- .use(Overlay)
- .use(DatetimePicker)
- .use(smallTip);
- export default {
- data() {
- const reviewer = [this.$userInfo()];
- let pts = this.$getTypes;
- let ptB = pts.filter(pt => pt.code === 'BF');
- ptB = ptB ? ptB[0] : null;
- return {
- showRuleSelector: false,
- isNeed: !this.$getCache('isAndroid'),
- bar_height: 0,
- task_expire_day_text: '',
- task_expire_day: 1,
- show_task_expire_day: false,
- columns1: [
- '01:00',
- '02:00',
- '03:00',
- '04:00',
- '05:00',
- '06:00',
- '07:00',
- '08:00',
- '09:00',
- '10:00',
- '11:00',
- '12:00',
- '13:00',
- '14:00',
- '15:00',
- '16:00',
- '17:00',
- '18:00',
- '19:00',
- '20:00',
- '21:00',
- '22:00',
- '23:00',
- '24:00'
- ],
- columns2: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
- columns3: [
- '1号',
- '2号',
- '3号',
- '4号',
- '5号',
- '6号',
- '7号',
- '8号',
- '9号',
- '10号',
- '11号',
- '12号',
- '13号',
- '14号',
- '15号',
- '16号',
- '17号',
- '18号',
- '19号',
- '20号',
- '21号',
- '22号',
- '23号',
- '24号',
- '25号',
- '26号',
- '27号',
- '28号',
- '29号',
- '30号',
- '31号'
- ],
- reviewer: reviewer,
- pts: pts,
- rule_items:[],
- rules:[],
- data: {
- rule_type:0,
- rule_id:0,
- item_id:0,
- rule_item:{
- id:0,
- remark:"",
- cycle_type: 0,
- is_attendance: 0,
- max_point: 0,
- min_point: 0,
- prize_type: 0,
- pt_id: 0,
- range_type: 0,
- rule_id: 0,
- },
- task_type: 1,
- pt_id: ptB ? ptB.id : 0,
- task_name: '',
- task_remark: '',
- base_point: 1,
- expire_time: '',
- file_list: [],
- reviewer_id: this.$userInfo().id,
- timeout_deduction_point: '',
- timeout_deduction_point_limit: '',
- ahead_award_point: '',
- ahead_award_point_limit: '',
- dept_ids: [],
- task_cycle: 0,
- task_expire_day: 1,
- schedule_expire_date:''
- },
- title: '发布悬赏任务',
- post_data: {},
- depts: [],
- show_task_cycle: false,
- show_task_super_satisfied: false,
- show_timeout_deduction_point: false,
- show_task_remark: false,
- show_task_cycle_popup: false,
- show_task_super_satisfied_popup: false,
- show_timeout_deduction_point_popup: false,
- show_task_remark_popup: false,
- flexDialog:false,
- showScheduleExpireDate:false,
- scheduleExpireDate:null
- };
- },
- components: {
- RuleScopeSelector,
- EmployeeSelectorCell,
- Mtextarea,
- DateTimeCell,
- DeptSelectorCell,
- smallTip,
- NumberInput,
- RuleCategorySelectorCell,
- CategorySelectorCell,
- },
- watch: {
- 'data.task_cycle': function(val) {
- this.data.task_expire_day = 1;
- this.task_expire_day = 0;
- this.scheduleExpireDate = null;
- if (this.data.task_cycle == 1) {
- this.task_expire_day_text = this.columns1[this.data.task_expire_day - 1];
- } else if (this.data.task_cycle == 2) {
- this.task_expire_day_text = this.columns2[this.data.task_expire_day - 1];
- } else if (this.data.task_cycle == 3) {
- this.task_expire_day_text = this.columns3[this.data.task_expire_day - 1];
- }
- },
- reviewer: function(val, old) {
- let self = this;
- if (val.length == 0) {
- self.data.reviewer_id = 0;
- } else {
- self.data.reviewer_id = val[0].id;
- }
- },
- depts(val) {
- if (val.length == 0) {
- this.data.dept_ids = [];
- } else {
- this.data.dept_ids = [];
- for (let i in val) {
- this.data.dept_ids.push(val[i].dept_id);
- }
- }
- },
- scheduleExpireDate(val){
- // console.log('悬赏 schedule expire date',val);
- this.data.schedule_expire_date = val ? moment(val).format('YYYY-MM-DD') : '';
- // console.log('悬赏',this.data);
- if (val) this.$toast("重复悬赏将在" + this.data.schedule_expire_date + "停止自动发布")
- },
- 'data.rule_type'(val){
- this.initRuleData()
- },
- rules(rules){
- this.data.rule_id = rules.length <= 0 ? 0 : rules[0].id
- },
- rule_items(items){
- this.data.rule_item = items.length <= 0 ? {
- id:0,
- remark:"",
- cycle_type: 0,
- is_attendance: 0,
- max_point: 0,
- min_point: 0,
- prize_type: 0,
- pt_id: 0,
- range_type: 0,
- rule_id: 0,
- } : {
- id:items[0].id,
- remark:items[0].remark,
- cycle_type: items[0].cycle_type,
- is_attendance: items[0].is_attendance,
- max_point: items[0].max_point,
- min_point: items[0].min_point,
- prize_type: items[0].prize_type,
- pt_id: items[0].pt_id,
- range_type: items[0].range_type,
- rule_id: items[0].rule_id,
- }
- this.data.rule_id = this.data.rule_item.rule_id
- this.data.item_id = this.data.rule_item.id
- this.data.base_point = this.data.rule_item.min_point !== 0 ? this.data.rule_item.min_point : 1
- },
- 'data.pt_id'(val){
- if (this.data.rule_type === 2) this.initRuleData()
- }
- },
- computed:{
- ruleItemLabel(){
- if (this.data.rule_item.id <= 0) return ''
- let pt = this.pts.find( t => t.id === this.data.rule_item.pt_id)
- return this.data.rule_item.range_type === 1 ? `${this.data.rule_item.min_point} ${pt.name}` : `${this.data.rule_item.min_point} - ${this.data.rule_item.max_point} ${pt.name}`
- },
- minPoint(){
- return this.data.rule_type !== 2 ? 1 : (this.data.rule_item.id <= 0 ? 1 : this.data.rule_item.min_point)
- },
- maxPoint(){
- return this.data.rule_type !== 2 ? 100000 : (this.data.rule_item.id <= 0 ? 1 : this.data.rule_item.max_point)
- }
- },
- methods: {
- del_task_cycle() {
- this.show_task_cycle = false;
- this.data.task_cycle = 0;
- },
- del_timeout_deduction_point() {
- this.show_timeout_deduction_point = false;
- this.data.timeout_deduction_point = 0;
- },
- del_task_remark() {
- this.data.task_remark = '';
- this.show_task_remark = false;
- },
- del_task_super_satisfied() {
- this.data.unqualified = 1;
- this.data.qualified = 1;
- this.data.satisfied = 1;
- this.data.super_satisfied = 1;
- this.show_task_super_satisfied = false;
- this.depts = [];
- this.data.dept_ids = [];
- },
- task_expire_dayonChange(val, index) {
- this.task_expire_day = index;
- if (this.data.task_cycle == 1) {
- this.task_expire_day_text = this.columns1[index];
- } else if (this.data.task_cycle == 2) {
- this.task_expire_day_text = this.columns2[index];
- } else if (this.data.task_cycle == 3) {
- this.task_expire_day_text = this.columns3[index];
- }
- this.data.task_expire_day = index + 1;
- this.show_task_expire_day = false;
- },
- save_remark() {
- this.show_task_remark = true;
- this.show_task_remark_popup = false;
- },
- save_timeout_deduction_point() {
- this.show_timeout_deduction_point = true;
- this.show_timeout_deduction_point_popup = false;
- },
- save_task_super_satisfied() {
- this.show_task_super_satisfied = true;
- this.show_task_super_satisfied_popup = false;
- },
- save_show_task_cycle() {
- this.show_task_cycle = true;
- this.show_task_cycle_popup = false;
- },
- showLoading() {
- this.$toast.loading({
- loadingType: 'spinner',
- message: '正在处理'
- });
- },
- ahead_timeout(item, arr, codes, code) {
- if (item) {
- if (arr) {
- if (Number(item) > Number(arr)) {
- this.$notify({ type: 'danger', message: code + '上限不能小于每日' + codes });
- return true;
- }
- } else {
- this.$notify({ type: 'danger', message: codes + '不为0时,' + code + '上限不能为空' });
- return true;
- }
- }
- },
- deletedata(data, arr) {
- data[arr] && data[arr] != 0 ? '' : delete data[arr];
- },
- sub() {
- let self = this;
- let url = '';
- if (self.data.task_cycle == 0) {
- url = '/api/pro/integral/task/publish';
- } else {
- url = '/api/pro/integral/schedule/publish/task';
- }
- let data = JSON.parse(JSON.stringify(self.data));
- if (data.task_remark == '') {
- delete data.task_remark;
- }
- if (data.unqualified == 0) {
- delete data.unqualified;
- }
- if (data.satisfied == 0) {
- delete data.satisfied;
- }
- if (data.qualified == 0) {
- delete data.qualified;
- }
- if (data.super_satisfied == 0) {
- delete data.super_satisfied;
- }
- if (!data.ahead_award_point && data.ahead_award_point_limit) {
- this.$notify({type: 'danger', message: '奖分上限不为0时,提前奖分不能为空'});
- return;
- } else if (data.ahead_award_point && !data.ahead_award_point_limit) {
- this.$notify({type: 'danger', message: '提前奖分不为0时,奖分上限不能为空'});
- return;
- }
- if (!data.timeout_deduction_point && data.timeout_deduction_point_limit) {
- this.$notify({type: 'danger', message: '扣分上限不为0时,逾期扣分不能为空'});
- return;
- } else if (data.timeout_deduction_point && !data.timeout_deduction_point_limit) {
- this.$notify({type: 'danger', message: '逾期扣分不为0时,扣分上限不能为空'});
- return;
- }
- if (this.ahead_timeout(data.ahead_award_point, data.ahead_award_point_limit, '提前奖分', '奖分')) return;
- if (this.ahead_timeout(data.timeout_deduction_point, data.timeout_deduction_point_limit, '逾期扣分', '扣分')) return;
- if (!this.$userInfo().is_creator || this.$userInfo().point_config.point_limit.length != 0) {
- let entry_limit = Number(this.$userInfo().point_config.point_limit[1].point);
- if (entry_limit > 0) {
- if (data.ahead_award_point > entry_limit || data.timeout_deduction_point > entry_limit) {
- this.$notify({ type: 'danger', message: '每日奖扣分 不能超过您的奖扣分权限(您的奖扣分权限:' + entry_limit + '分)' });
- return;
- }
- if (data.ahead_award_point_limit > entry_limit * 10 || data.timeout_deduction_point_limit > entry_limit * 10) {
- this.$notify({ type: 'danger', message: '奖扣分上限不能超过' + entry_limit * 10 + '分(您的奖扣分权限' + entry_limit + '分*10)' });
- return;
- }
- }
- }
- let add = ['ahead_award_point', 'ahead_award_point_limit', 'timeout_deduction_point', 'timeout_deduction_point_limit'];
- add.forEach(item => {
- this.deletedata(data, item);
- });
- this.showLoading();
- let is=true;
- if(this.data.task_cycle==1&&this.data.task_expire_day<=moment().format('HH')){
- is=false
- }else if(this.data.task_cycle==2&&this.data.task_expire_day<=moment().day()){
- is=false
- }else if(this.data.task_cycle==3&&this.data.task_expire_day<=moment().format('D')){
- is=false
- }
- if (!data.schedule_expire_date) delete data.schedule_expire_date;
- this.$axiosUser('post', url, data).then(res => {
- if(this.data.task_cycle&&is){
- let str=this.data.task_cycle==1? '您发布的每日重复任务将于明天0点执行自动发布,是否需要立即发布一条任务?':this.data.task_cycle==2? '您发布的每周重复任务将于下周一执行自动发布,是否需要立即发布一条任务?':'您发布的每月重复任务将于下个月1号执行自动发布,是否需要立即发布一条任务?'
- this.$dialog.confirm({
- message: str,
- confirmButtonText:'发布',
- cancelButtonText:'不需要',
- }).then(() => {
- this.executeTask(res.data.data)
- }).catch(() => {
- if (window.plus) {
- setTimeout(() => {
- plus.navigator.setStatusBarStyle('dark');
- document.documentElement.style.backgroundColor = '#fff';
- }, 100);
- }
- this.initData();
- localStorage.setItem('callback_data', JSON.stringify({ title: '发布成功', detail_url: '' }));
- this.$router.replace({ path: '/callback?replace=1' });
- });
- }else{
- if (window.plus) {
- setTimeout(() => {
- plus.navigator.setStatusBarStyle('dark');
- document.documentElement.style.backgroundColor = '#fff';
- }, 100);
- }
- localStorage.setItem('callback_data', JSON.stringify({ title: '发布成功', detail_url: '' }));
- this.$router.replace({ path: '/callback?replace=1' });
- }
- }).finally(e => {
- this.$toast.clear();
- });
- },
- initRuleData(){
- this.data.rule_id = 0
- this.data.item_id = 0
- this.data.rule_item = {
- id:0,
- remark:"",
- cycle_type: 0,
- is_attendance: 0,
- max_point: 0,
- min_point: 0,
- prize_type: 0,
- pt_id: 0,
- range_type: 0,
- rule_id: 0,
- }
- this.data.base_point = 1
- this.rule_items = []
- this.rules = []
- },
- initData(){
- this.reviewer = [];
- this.data = {
- task_type: 1,
- pt_id: 0,
- task_name: '',
- task_remark: '',
- base_point: 1,
- expire_time: '',
- file_list: [],
- reviewer_id: 0,
- timeout_deduction_point: '',
- timeout_deduction_point_limit: '',
- ahead_award_point: '',
- ahead_award_point_limit: '',
- dept_ids: [],
- task_cycle: 0,
- task_expire_day: 1,
- schedule_expire_date: ''
- };
- },
- //执行周期任务
- executeTask(id){
- this.$axiosUser('POST', '/api/pro/integral/schedule/hand_exec',{schedule_id:id}).then(res => {
- this.$toast('已发布');
- if (window.plus) {
- setTimeout(() => {
- plus.navigator.setStatusBarStyle('dark');
- document.documentElement.style.backgroundColor = '#fff';
- }, 100);
- }
- this.initData();
- localStorage.setItem('callback_data', JSON.stringify({ title: '发布成功', detail_url: '' }));
- this.$router.replace({ path: '/callback?replace=1' });
- });
- },
- sava_btn() {
- // console.log('悬赏 sava_btn',this.data);return;
- if (this.data.rule_type === 1 && this.data.rule_id <= 0){
- this.$toast.fail ("请选择规则分类")
- return
- }
- if (this.data.rule_type === 2 && this.data.item_id <= 0){
- this.$toast.fail('请选择积分规则')
- return;
- }
- if (this.data.base_point <= 0) {
- this.$toast.fail('积分必须大于0')
- return;
- }
- let self = this;
- self.$validator.validate().then(result => {
- if (!result) {
- self.$notify({ type: 'danger', message: self.$validator.errors.items[0].msg });
- } else {
- if (self.data.base_point === 0) {
- self.$notify({ type: 'danger', message: '任务积分不能为0' });
- } else {
- self.sub();
- }
- }
- });
- },
- scheduleExpireDateConfirm(val) {
- this.showScheduleExpireDate = false;
- this.scheduleExpireDate = val;
- },
- clearScheduleExpireDate() {
- this.showScheduleExpireDate = false;
- this.scheduleExpireDate = null;
- }
- },
- created() {
- if (window.plus) {
- this.bar_height = window.plus.navigator.getStatusbarHeight();
- if(!this.$getCache('flexDialog')){
- this.flexDialog=true;
- this.$setCache('flexDialog',true);
- }
- }
- }
- };
- </script>
- <style rel="stylesheet/less" lang="less" scoped>
- .flexDiaWb{
- max-height: 7rem;
- overflow-y: auto;
- overflow-x: hidden;
- margin: 0.4rem 0;
- padding: 0 0.2rem 0 0.3rem;
- }
- /deep/ .van-field__label {
- width: 2.4rem;
- }
- .body_com {
- height: calc(100% - 0.92rem);
- position: relative;
- overflow-y: scroll;
- }
- .task_move {
- margin: 0.32rem;
- margin-bottom: 0;
- background-color: #fff;
- padding: 0.2rem;
- .van-row {
- .van-col {
- position: relative;
- text-align: center;
- padding: 0.2rem;
- font-size: 0.32rem;
- padding-left: 0;
- padding-right: 0;
- .icon {
- width: 0.32rem;
- height: 0.36rem;
- }
- &:after {
- content: '';
- display: block;
- height: 0.3rem;
- background-color: #dcdfe6;
- width: 0.02rem;
- clear: both;
- right: 0;
- position: absolute;
- top: 0.3rem;
- }
- }
- }
- }
- .all_popup {
- height: 100vh;
- width: 100vw;
- background-color: rgb(245, 245, 245);
- }
- .point_popup_tip {
- font-size: 0.24rem;
- color: #909399;
- line-height: 0.34rem;
- background-color: rgb(245, 245, 245);
- span {
- color: #26a2ff;
- }
- }
- .red {
- color: red;
- }
- .van-popup {
- background: rgb(245, 245, 245);
- }
- .van-col.van-col--8 {
- margin-bottom: 0.16rem;
- }
- /deep/ .depts_cell .van-cell__value {
- -webkit-box-flex: unset;
- -webkit-flex: none;
- flex: none;
- width: 4rem !important;
- }
- /deep/ .van-col.van-col--8 .van-button {
- padding: 0;
- }
- .point-field /deep/ .van-cell__title.van-field__label span {
- width: 0;
- color: transparent;
- height: 0;
- overflow: hidden;
- font-size: 0;
- }
- .point-field /deep/ .van-cell__title {
- width: 0;
- }
- .temp_task_box /deep/ .van-icon-close {
- color: #238dfa;
- padding-top: 0.1rem;
- }
- .temp_task_box .choose_button {
- padding-top: 0.2rem;
- background: #fff;
- border-radius: 0.08rem;
- }
- .temp_task_box .choose_button .list {
- }
- .temp_task_box .choose_button .list /deep/ button {
- height: 0.4rem;
- margin: 0.16rem auto;
- border: none;
- border-right: 0.02rem #dcdfe6 solid;
- line-height: 0.4rem;
- }
- .temp_task_box .choose_button .list /deep/ button:hover {
- color: #238dfa;
- background: transparent;
- }
- .temp_task_box .choose_button .list /deep/ button:active {
- color: #238dfa;
- background: transparent;
- }
- .temp_task_box .choose_button .list /deep/ button:before {
- background: transparent;
- }
- .temp_task_box .choose_button .list:nth-child(3) /deep/ button {
- border-right: none;
- }
- .radio_button /deep/ .changeRadio .van-radio__icon {
- background-color: rgba(38, 162, 255, 0.2) !important;
- }
- .radio_button /deep/.changeRadio .van-radio__icon--checked + .van-radio__label {
- color: #26a2ff !important;
- }
- .temp_task_box .small_tip_content p:nth-child(3) {
- display: none;
- }
- .rule_type_span {
- font-size: 0.25rem;
- line-height: 0.5rem;
- }
- </style>
|