temp_task.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. <template>
  2. <div class="temp_task_box">
  3. <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>
  4. <div class="body_com">
  5. <scroller :isNeed="isNeed">
  6. <van-cell-group>
  7. <van-cell>
  8. <Mtextarea
  9. v-model="data.task_name"
  10. placeholder="请输入关于任务内容"
  11. required
  12. v-validate="'required|max:20'"
  13. name="任务内容"
  14. :text_max="20"
  15. :imgs_max="3"
  16. images
  17. :imgs.sync="data.file_list"
  18. />
  19. </van-cell>
  20. </van-cell-group>
  21. <van-cell-group class="point-field">
  22. <van-cell title="积分类型" required>
  23. <template slot="right-icon">
  24. <van-radio-group v-model="data.pt_id" direction="horizontal" class="radio_button">
  25. <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">
  26. {{ item.name }}
  27. </van-radio>
  28. </van-radio-group>
  29. <!-- <smallTip icon="question-o" position="30%">-->
  30. <!-- <p style="margin: 0; line-height: 0.6rem">A分:物质分,与钱直接挂钩</p>-->
  31. <!-- <p style="margin: 0; line-height: 0.6rem">B分:福利分,与福利待遇挂钩</p>-->
  32. <!-- <p style="margin: 0; line-height: 0.6rem">绩效分:工作分,与绩效考核挂钩</p>-->
  33. <!-- </smallTip>-->
  34. </template>
  35. </van-cell>
  36. <van-cell title="指定规则">
  37. <template slot="right-icon">
  38. <van-radio-group
  39. v-model="data.rule_type"
  40. direction="horizontal"
  41. class="radio_button"
  42. >
  43. <van-radio class="list" :name="0" >
  44. <span class="rule_type_span">不指定</span>
  45. </van-radio>
  46. <van-radio class="list" :name="1" >
  47. <span class="rule_type_span">分类</span>
  48. </van-radio>
  49. <van-radio class="list" :name="2" >
  50. <span class="rule_type_span">规则</span>
  51. </van-radio>
  52. </van-radio-group>
  53. </template>
  54. </van-cell>
  55. <!-- 选择分类 -->
  56. <CategorySelectorCell
  57. v-if="data.rule_type === 1"
  58. title="细则分类"
  59. v-model="rules"
  60. required
  61. :pt-id="data.pt_id"
  62. :multi="false"
  63. scope
  64. />
  65. <!--选择规则 -->
  66. <van-cell
  67. v-if="data.rule_type === 2"
  68. title="积分规则"
  69. @click="showRuleSelector = true"
  70. required
  71. :value="rule_items.length <= 0 ? '' : `已选${rule_items.length}条`"
  72. />
  73. <RuleScopeSelector :visible.sync = showRuleSelector :selected="rule_items" @confirm="selected => rule_items = selected" :pt-id="data.pt_id" />
  74. <!-- <RuleCategorySelectorCell-->
  75. <!-- v-if="data.rule_type === 2"-->
  76. <!-- :pt-id="data.pt_id"-->
  77. <!-- required-->
  78. <!-- name="请选择积分规则"-->
  79. <!-- title="积分规则"-->
  80. <!-- v-model="rule_items"-->
  81. <!-- scope-->
  82. <!-- :multi="false"-->
  83. <!-- >-->
  84. <!-- <template slot="label">-->
  85. <!-- <span style="color: red">{{ruleItemLabel}}</span>-->
  86. <!-- </template>-->
  87. <!-- </RuleCategorySelectorCell>-->
  88. <van-cell title="任务积分" style="padding:0 0.32rem; padding-top:0.16rem;" :border="false" required />
  89. <NumberInput v-model="data.base_point" v-validate="'required'" :min="minPoint" :max="maxPoint"/>
  90. </van-cell-group>
  91. <van-cell-group>
  92. <EmployeeSelectorCell
  93. title="审批人"
  94. name="审批人"
  95. iconType="records"
  96. required
  97. v-validate="'required'"
  98. :show_manager_only="true"
  99. v-model="reviewer"
  100. :multi="false"
  101. ></EmployeeSelectorCell>
  102. <van-cell title="重复周期" @click="show_task_cycle_popup = true">
  103. <template>
  104. <span v-if="data.task_cycle == 0">不重复</span>
  105. <span v-if="data.task_cycle == 1">每天重复</span>
  106. <span v-if="data.task_cycle == 2">每周重复</span>
  107. <span v-if="data.task_cycle == 3">每月重复</span>
  108. </template>
  109. </van-cell>
  110. <DateTimeCell title="截止时间" required v-validate="'required'" name="截止时间" v-if="data.task_cycle == 0" v-model="data.expire_time"></DateTimeCell>
  111. <van-cell :value="'每天' + task_expire_day_text" is-link @click="show_task_expire_day = true" title="截止时间" v-if="data.task_cycle == 1" />
  112. <van-cell :value="'每' + task_expire_day_text" is-link @click="show_task_expire_day = true" title="截止时间" v-if="data.task_cycle == 2" />
  113. <van-cell :value="'每月' + task_expire_day_text" is-link @click="show_task_expire_day = true" title="截止时间" v-if="data.task_cycle == 3" />
  114. <van-cell title="有效日期" v-if="data.task_cycle !== 0" @click="showScheduleExpireDate = true" :value="data.schedule_expire_date" :center="true">
  115. <template #right-icon >
  116. <van-icon color="#A4A5A7" name="arrow" v-if="!data.schedule_expire_date" />
  117. <van-icon color="#A4A5A7" name="close" v-else @click.stop="clearScheduleExpireDate" style="margin-left: 10px" />
  118. </template>
  119. </van-cell>
  120. <van-field v-model="data.ahead_award_point" type="digit">
  121. <template slot="label">
  122. <div class="flex-box-ce">
  123. <span>提前奖分(天)</span>
  124. <span class="flex-1 red" style="text-align: right;">+</span>
  125. </div>
  126. </template>
  127. </van-field>
  128. <van-field v-model="data.ahead_award_point_limit" type="digit" label="奖分上限">
  129. <template slot="label">
  130. <div class="flex-box-ce">
  131. <span>奖分上限</span>
  132. <span class="flex-1 red" style="text-align: right;">+</span>
  133. </div>
  134. </template>
  135. </van-field>
  136. <van-field v-model="data.timeout_deduction_point" type="digit" label="逾期扣分(天)">
  137. <template slot="label">
  138. <div class="flex-box-ce">
  139. <span>逾期扣分(天)</span>
  140. <span class="flex-1 green" style="text-align: right;">-</span>
  141. </div>
  142. </template>
  143. </van-field>
  144. <van-field v-model="data.timeout_deduction_point_limit" type="digit" label="扣分上限">
  145. <template slot="label">
  146. <div class="flex-box-ce">
  147. <span>扣分上限</span>
  148. <span class="flex-1 green" style="text-align: right;">-</span>
  149. </div>
  150. </template>
  151. </van-field>
  152. </van-cell-group>
  153. <van-cell-group :border="false">
  154. <van-cell icon="records" v-if="show_task_remark" title="任务备注" :label="data.task_remark" @click="show_task_remark_popup = true">
  155. <template slot="right-icon">
  156. <van-icon name="close" @click.stop="del_task_remark" />
  157. </template>
  158. </van-cell>
  159. <van-cell class="depts_cell" icon="eye-o" v-if="show_task_super_satisfied" title="可见范围" @click="show_task_super_satisfied_popup = true">
  160. <template slot="right-icon">
  161. <van-icon name="close" @click.stop="del_task_super_satisfied" />
  162. </template>
  163. <template slot="label">
  164. <div style="display: inline;" class="employee_cell_value" v-if="depts.length <= 2">
  165. <span v-for="(item, index) in depts" :key="index">
  166. <em v-show="index > 0">,</em>
  167. {{ item.dept_name }}
  168. </span>
  169. </div>
  170. <div style="display: inline;" class="employee_cell_value" v-if="depts.length > 2">
  171. <span v-for="(item, index) in depts" v-if="index < 2" :key="index">
  172. <em v-show="index > 0">,</em>
  173. {{ item.dept_name }}
  174. </span>
  175. 等{{ depts.length }}个
  176. </div>
  177. </template>
  178. </van-cell>
  179. </van-cell-group>
  180. <div style="padding:0.32rem;">
  181. <van-row gutter="5" class="choose_button">
  182. <van-col class="list" span="12" v-if="!show_task_remark">
  183. <van-button @click="show_task_remark_popup = true" type="default" block icon="records">任务备注</van-button>
  184. </van-col>
  185. <van-col class="list" span="12" v-if="!show_task_super_satisfied">
  186. <van-button @click="show_task_super_satisfied_popup = true" type="default" block icon="eye-o">可见范围</van-button>
  187. </van-col>
  188. </van-row>
  189. </div>
  190. <div style="padding: 0.32rem"><van-button type="info" block @click="sava_btn">提交</van-button></div>
  191. <div style="height: 1rem;"></div>
  192. </scroller>
  193. </div>
  194. <van-popup v-model="show_task_cycle_popup" position="right" style="height:100%; width:100%;">
  195. <div :style="'padding-top:' + bar_height + 'px;background-color: #238dfa;'"></div>
  196. <van-nav-bar
  197. title="重复周期"
  198. left-text="返回"
  199. @click-left="show_task_cycle_popup = false"
  200. left-arrow
  201. right-arrow
  202. @click-right="save_show_task_cycle"
  203. right-text="保存"
  204. ></van-nav-bar>
  205. <div style="padding: 0.2rem 0.32rem 0; font-size: 0.26rem;" class="fontColorC" v-show="data.task_cycle == 0">任务为一次性任务</div>
  206. <div style="padding: 0.2rem 0.32rem 0; font-size: 0.26rem;" class="fontColorC" v-show="data.task_cycle == 1">任务每天0点自动发布</div>
  207. <div style="padding: 0.2rem 0.32rem 0; font-size: 0.26rem;" class="fontColorC" v-show="data.task_cycle == 2">任务每周周一自动发布</div>
  208. <div style="padding: 0.2rem 0.32rem 0; font-size: 0.26rem;" class="fontColorC" v-show="data.task_cycle == 3">任务每月1号自动发布</div>
  209. <van-radio-group v-model="data.task_cycle">
  210. <van-cell-group>
  211. <van-cell title="不重复" clickable @click="data.task_cycle = 0">
  212. <template slot="right-icon">
  213. <van-radio :name="0" />
  214. </template>
  215. </van-cell>
  216. <van-cell title="每天重复" clickable @click="data.task_cycle = 1">
  217. <template slot="right-icon">
  218. <van-radio :name="1" />
  219. </template>
  220. </van-cell>
  221. <van-cell title="每周重复" clickable @click="data.task_cycle = 2">
  222. <template slot="right-icon">
  223. <van-radio :name="2" />
  224. </template>
  225. </van-cell>
  226. <van-cell title="每月重复" clickable @click="data.task_cycle = 3">
  227. <template slot="right-icon">
  228. <van-radio :name="3" />
  229. </template>
  230. </van-cell>
  231. </van-cell-group>
  232. </van-radio-group>
  233. </van-popup>
  234. <van-popup v-model="show_task_super_satisfied_popup" position="right" style="height:100%; width:100%;">
  235. <div :style="'padding-top:' + bar_height + 'px;background-color: #238dfa;'"></div>
  236. <van-nav-bar
  237. title="可见范围"
  238. left-text="返回"
  239. @click-left="show_task_super_satisfied_popup = false"
  240. left-arrow
  241. right-arrow
  242. @click-right="save_task_super_satisfied"
  243. right-text="保存"
  244. ></van-nav-bar>
  245. <van-cell-group v-if="show_task_super_satisfied_popup"><DeptSelectorCell title="可见范围" v-model="depts"></DeptSelectorCell></van-cell-group>
  246. </van-popup>
  247. <van-popup v-model="show_timeout_deduction_point_popup" position="right" style="height:100%; width:100%;">
  248. <div :style="'padding-top:' + bar_height + 'px;background-color: #238dfa;'"></div>
  249. <van-nav-bar
  250. title="逾期扣分"
  251. left-text="返回"
  252. @click-left="show_timeout_deduction_point_popup = false"
  253. left-arrow
  254. right-arrow
  255. @click-right="save_timeout_deduction_point"
  256. right-text="保存"
  257. ></van-nav-bar>
  258. <van-cell-group v-if="show_timeout_deduction_point_popup">
  259. <div class="point_popup_tip red" slot="title">每逾期一天扣多少分</div>
  260. <van-field type="number" v-model="data.timeout_deduction_point" placeholder="请输入积分" label="扣除分值" />
  261. </van-cell-group>
  262. </van-popup>
  263. <van-dialog v-model="flexDialog" title="" width="350" :show-confirm-button="false" closeOnClickOverlay>
  264. <div class="flexDiaWb">
  265. <h3>悬赏任务</h3>
  266. <p style="color: #3F4755;">公开悬赏任务到某个部门或全公司,员工抢做任务负责人,完成可审批打分,也支持设置自动重复发布</p>
  267. <div style="text-align: right;padding: 10px 0;" @click="flexDialog=false">我知道了</div>
  268. </div>
  269. </van-dialog>
  270. <van-popup v-model="show_task_remark_popup" position="right" style="height:100%; width:100%;">
  271. <div :style="'padding-top:' + bar_height + 'px;background-color: #238dfa;'"></div>
  272. <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>
  273. <van-cell-group v-if="show_task_remark_popup">
  274. <van-cell><Mtextarea v-model="data.task_remark" placeholder="请输入关于任务备注" :text_max="100"></Mtextarea></van-cell>
  275. </van-cell-group>
  276. </van-popup>
  277. <van-popup v-model="show_task_expire_day" position="bottom">
  278. <van-picker
  279. :columns="columns1"
  280. :default-index="task_expire_day"
  281. v-show="data.task_cycle == 1"
  282. show-toolbar
  283. @cancel="show_task_expire_day = false"
  284. @confirm="task_expire_dayonChange"
  285. />
  286. <van-picker
  287. :columns="columns2"
  288. :default-index="task_expire_day"
  289. v-show="data.task_cycle == 2"
  290. show-toolbar
  291. @cancel="show_task_expire_day = false"
  292. @confirm="task_expire_dayonChange"
  293. />
  294. <van-picker
  295. :columns="columns3"
  296. :default-index="task_expire_day"
  297. v-show="data.task_cycle == 3"
  298. show-toolbar
  299. @cancel="show_task_expire_day = false"
  300. @confirm="task_expire_dayonChange"
  301. />
  302. </van-popup>
  303. <van-calendar
  304. title="有效日期"
  305. color="#26A2FF"
  306. v-model="showScheduleExpireDate"
  307. :show-confirm="false"
  308. :default-date="scheduleExpireDate"
  309. @confirm="scheduleExpireDateConfirm"
  310. />
  311. </div>
  312. </template>
  313. <script>
  314. import DeptSelectorCell from '@/components/DeptSelectorCell';
  315. import DateTimeCell from '@/components/DateTimeCell';
  316. import RuleCategorySelectorCell from '@/components/RuleCategorySelectorCell1'
  317. import CategorySelectorCell from '@/components/CategorySelectorCell'
  318. import NumberInput from '@/components/NumberInput';
  319. import Vue from 'vue';
  320. import moment from 'moment'
  321. import Mtextarea from '@/components/Mtextarea';
  322. import EmployeeSelectorCell from '@/components/EmployeeSelectorCell';
  323. import smallTip from '@/components/smallTip';
  324. import { calendar, Overlay, DatetimePicker, RadioGroup, Radio, Picker } from 'vant';
  325. import RuleScopeSelector from "../../../components/RuleScopeSelector.vue";
  326. Vue.use(Radio);
  327. Vue.use(Picker);
  328. Vue.use(RadioGroup);
  329. Vue.use(calendar)
  330. .use(Overlay)
  331. .use(DatetimePicker)
  332. .use(smallTip);
  333. export default {
  334. data() {
  335. const reviewer = [this.$userInfo()];
  336. let pts = this.$getTypes;
  337. let ptB = pts.filter(pt => pt.code === 'BF');
  338. ptB = ptB ? ptB[0] : null;
  339. return {
  340. showRuleSelector: false,
  341. isNeed: !this.$getCache('isAndroid'),
  342. bar_height: 0,
  343. task_expire_day_text: '',
  344. task_expire_day: 1,
  345. show_task_expire_day: false,
  346. columns1: [
  347. '01:00',
  348. '02:00',
  349. '03:00',
  350. '04:00',
  351. '05:00',
  352. '06:00',
  353. '07:00',
  354. '08:00',
  355. '09:00',
  356. '10:00',
  357. '11:00',
  358. '12:00',
  359. '13:00',
  360. '14:00',
  361. '15:00',
  362. '16:00',
  363. '17:00',
  364. '18:00',
  365. '19:00',
  366. '20:00',
  367. '21:00',
  368. '22:00',
  369. '23:00',
  370. '24:00'
  371. ],
  372. columns2: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  373. columns3: [
  374. '1号',
  375. '2号',
  376. '3号',
  377. '4号',
  378. '5号',
  379. '6号',
  380. '7号',
  381. '8号',
  382. '9号',
  383. '10号',
  384. '11号',
  385. '12号',
  386. '13号',
  387. '14号',
  388. '15号',
  389. '16号',
  390. '17号',
  391. '18号',
  392. '19号',
  393. '20号',
  394. '21号',
  395. '22号',
  396. '23号',
  397. '24号',
  398. '25号',
  399. '26号',
  400. '27号',
  401. '28号',
  402. '29号',
  403. '30号',
  404. '31号'
  405. ],
  406. reviewer: reviewer,
  407. pts: pts,
  408. rule_items:[],
  409. rules:[],
  410. data: {
  411. rule_type:0,
  412. rule_id:0,
  413. item_id:0,
  414. rule_item:{
  415. id:0,
  416. remark:"",
  417. cycle_type: 0,
  418. is_attendance: 0,
  419. max_point: 0,
  420. min_point: 0,
  421. prize_type: 0,
  422. pt_id: 0,
  423. range_type: 0,
  424. rule_id: 0,
  425. },
  426. task_type: 1,
  427. pt_id: ptB ? ptB.id : 0,
  428. task_name: '',
  429. task_remark: '',
  430. base_point: 1,
  431. expire_time: '',
  432. file_list: [],
  433. reviewer_id: this.$userInfo().id,
  434. timeout_deduction_point: '',
  435. timeout_deduction_point_limit: '',
  436. ahead_award_point: '',
  437. ahead_award_point_limit: '',
  438. dept_ids: [],
  439. task_cycle: 0,
  440. task_expire_day: 1,
  441. schedule_expire_date:''
  442. },
  443. title: '发布悬赏任务',
  444. post_data: {},
  445. depts: [],
  446. show_task_cycle: false,
  447. show_task_super_satisfied: false,
  448. show_timeout_deduction_point: false,
  449. show_task_remark: false,
  450. show_task_cycle_popup: false,
  451. show_task_super_satisfied_popup: false,
  452. show_timeout_deduction_point_popup: false,
  453. show_task_remark_popup: false,
  454. flexDialog:false,
  455. showScheduleExpireDate:false,
  456. scheduleExpireDate:null
  457. };
  458. },
  459. components: {
  460. RuleScopeSelector,
  461. EmployeeSelectorCell,
  462. Mtextarea,
  463. DateTimeCell,
  464. DeptSelectorCell,
  465. smallTip,
  466. NumberInput,
  467. RuleCategorySelectorCell,
  468. CategorySelectorCell,
  469. },
  470. watch: {
  471. 'data.task_cycle': function(val) {
  472. this.data.task_expire_day = 1;
  473. this.task_expire_day = 0;
  474. this.scheduleExpireDate = null;
  475. if (this.data.task_cycle == 1) {
  476. this.task_expire_day_text = this.columns1[this.data.task_expire_day - 1];
  477. } else if (this.data.task_cycle == 2) {
  478. this.task_expire_day_text = this.columns2[this.data.task_expire_day - 1];
  479. } else if (this.data.task_cycle == 3) {
  480. this.task_expire_day_text = this.columns3[this.data.task_expire_day - 1];
  481. }
  482. },
  483. reviewer: function(val, old) {
  484. let self = this;
  485. if (val.length == 0) {
  486. self.data.reviewer_id = 0;
  487. } else {
  488. self.data.reviewer_id = val[0].id;
  489. }
  490. },
  491. depts(val) {
  492. if (val.length == 0) {
  493. this.data.dept_ids = [];
  494. } else {
  495. this.data.dept_ids = [];
  496. for (let i in val) {
  497. this.data.dept_ids.push(val[i].dept_id);
  498. }
  499. }
  500. },
  501. scheduleExpireDate(val){
  502. // console.log('悬赏 schedule expire date',val);
  503. this.data.schedule_expire_date = val ? moment(val).format('YYYY-MM-DD') : '';
  504. // console.log('悬赏',this.data);
  505. if (val) this.$toast("重复悬赏将在" + this.data.schedule_expire_date + "停止自动发布")
  506. },
  507. 'data.rule_type'(val){
  508. this.initRuleData()
  509. },
  510. rules(rules){
  511. this.data.rule_id = rules.length <= 0 ? 0 : rules[0].id
  512. },
  513. rule_items(items){
  514. this.data.rule_item = items.length <= 0 ? {
  515. id:0,
  516. remark:"",
  517. cycle_type: 0,
  518. is_attendance: 0,
  519. max_point: 0,
  520. min_point: 0,
  521. prize_type: 0,
  522. pt_id: 0,
  523. range_type: 0,
  524. rule_id: 0,
  525. } : {
  526. id:items[0].id,
  527. remark:items[0].remark,
  528. cycle_type: items[0].cycle_type,
  529. is_attendance: items[0].is_attendance,
  530. max_point: items[0].max_point,
  531. min_point: items[0].min_point,
  532. prize_type: items[0].prize_type,
  533. pt_id: items[0].pt_id,
  534. range_type: items[0].range_type,
  535. rule_id: items[0].rule_id,
  536. }
  537. this.data.rule_id = this.data.rule_item.rule_id
  538. this.data.item_id = this.data.rule_item.id
  539. this.data.base_point = this.data.rule_item.min_point !== 0 ? this.data.rule_item.min_point : 1
  540. },
  541. 'data.pt_id'(val){
  542. if (this.data.rule_type === 2) this.initRuleData()
  543. }
  544. },
  545. computed:{
  546. ruleItemLabel(){
  547. if (this.data.rule_item.id <= 0) return ''
  548. let pt = this.pts.find( t => t.id === this.data.rule_item.pt_id)
  549. 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}`
  550. },
  551. minPoint(){
  552. return this.data.rule_type !== 2 ? 1 : (this.data.rule_item.id <= 0 ? 1 : this.data.rule_item.min_point)
  553. },
  554. maxPoint(){
  555. return this.data.rule_type !== 2 ? 100000 : (this.data.rule_item.id <= 0 ? 1 : this.data.rule_item.max_point)
  556. }
  557. },
  558. methods: {
  559. del_task_cycle() {
  560. this.show_task_cycle = false;
  561. this.data.task_cycle = 0;
  562. },
  563. del_timeout_deduction_point() {
  564. this.show_timeout_deduction_point = false;
  565. this.data.timeout_deduction_point = 0;
  566. },
  567. del_task_remark() {
  568. this.data.task_remark = '';
  569. this.show_task_remark = false;
  570. },
  571. del_task_super_satisfied() {
  572. this.data.unqualified = 1;
  573. this.data.qualified = 1;
  574. this.data.satisfied = 1;
  575. this.data.super_satisfied = 1;
  576. this.show_task_super_satisfied = false;
  577. this.depts = [];
  578. this.data.dept_ids = [];
  579. },
  580. task_expire_dayonChange(val, index) {
  581. this.task_expire_day = index;
  582. if (this.data.task_cycle == 1) {
  583. this.task_expire_day_text = this.columns1[index];
  584. } else if (this.data.task_cycle == 2) {
  585. this.task_expire_day_text = this.columns2[index];
  586. } else if (this.data.task_cycle == 3) {
  587. this.task_expire_day_text = this.columns3[index];
  588. }
  589. this.data.task_expire_day = index + 1;
  590. this.show_task_expire_day = false;
  591. },
  592. save_remark() {
  593. this.show_task_remark = true;
  594. this.show_task_remark_popup = false;
  595. },
  596. save_timeout_deduction_point() {
  597. this.show_timeout_deduction_point = true;
  598. this.show_timeout_deduction_point_popup = false;
  599. },
  600. save_task_super_satisfied() {
  601. this.show_task_super_satisfied = true;
  602. this.show_task_super_satisfied_popup = false;
  603. },
  604. save_show_task_cycle() {
  605. this.show_task_cycle = true;
  606. this.show_task_cycle_popup = false;
  607. },
  608. showLoading() {
  609. this.$toast.loading({
  610. loadingType: 'spinner',
  611. message: '正在处理'
  612. });
  613. },
  614. ahead_timeout(item, arr, codes, code) {
  615. if (item) {
  616. if (arr) {
  617. if (Number(item) > Number(arr)) {
  618. this.$notify({ type: 'danger', message: code + '上限不能小于每日' + codes });
  619. return true;
  620. }
  621. } else {
  622. this.$notify({ type: 'danger', message: codes + '不为0时,' + code + '上限不能为空' });
  623. return true;
  624. }
  625. }
  626. },
  627. deletedata(data, arr) {
  628. data[arr] && data[arr] != 0 ? '' : delete data[arr];
  629. },
  630. sub() {
  631. let self = this;
  632. let url = '';
  633. if (self.data.task_cycle == 0) {
  634. url = '/api/pro/integral/task/publish';
  635. } else {
  636. url = '/api/pro/integral/schedule/publish/task';
  637. }
  638. let data = JSON.parse(JSON.stringify(self.data));
  639. if (data.task_remark == '') {
  640. delete data.task_remark;
  641. }
  642. if (data.unqualified == 0) {
  643. delete data.unqualified;
  644. }
  645. if (data.satisfied == 0) {
  646. delete data.satisfied;
  647. }
  648. if (data.qualified == 0) {
  649. delete data.qualified;
  650. }
  651. if (data.super_satisfied == 0) {
  652. delete data.super_satisfied;
  653. }
  654. if (!data.ahead_award_point && data.ahead_award_point_limit) {
  655. this.$notify({type: 'danger', message: '奖分上限不为0时,提前奖分不能为空'});
  656. return;
  657. } else if (data.ahead_award_point && !data.ahead_award_point_limit) {
  658. this.$notify({type: 'danger', message: '提前奖分不为0时,奖分上限不能为空'});
  659. return;
  660. }
  661. if (!data.timeout_deduction_point && data.timeout_deduction_point_limit) {
  662. this.$notify({type: 'danger', message: '扣分上限不为0时,逾期扣分不能为空'});
  663. return;
  664. } else if (data.timeout_deduction_point && !data.timeout_deduction_point_limit) {
  665. this.$notify({type: 'danger', message: '逾期扣分不为0时,扣分上限不能为空'});
  666. return;
  667. }
  668. if (this.ahead_timeout(data.ahead_award_point, data.ahead_award_point_limit, '提前奖分', '奖分')) return;
  669. if (this.ahead_timeout(data.timeout_deduction_point, data.timeout_deduction_point_limit, '逾期扣分', '扣分')) return;
  670. if (!this.$userInfo().is_creator || this.$userInfo().point_config.point_limit.length != 0) {
  671. let entry_limit = Number(this.$userInfo().point_config.point_limit[1].point);
  672. if (entry_limit > 0) {
  673. if (data.ahead_award_point > entry_limit || data.timeout_deduction_point > entry_limit) {
  674. this.$notify({ type: 'danger', message: '每日奖扣分 不能超过您的奖扣分权限(您的奖扣分权限:' + entry_limit + '分)' });
  675. return;
  676. }
  677. if (data.ahead_award_point_limit > entry_limit * 10 || data.timeout_deduction_point_limit > entry_limit * 10) {
  678. this.$notify({ type: 'danger', message: '奖扣分上限不能超过' + entry_limit * 10 + '分(您的奖扣分权限' + entry_limit + '分*10)' });
  679. return;
  680. }
  681. }
  682. }
  683. let add = ['ahead_award_point', 'ahead_award_point_limit', 'timeout_deduction_point', 'timeout_deduction_point_limit'];
  684. add.forEach(item => {
  685. this.deletedata(data, item);
  686. });
  687. this.showLoading();
  688. let is=true;
  689. if(this.data.task_cycle==1&&this.data.task_expire_day<=moment().format('HH')){
  690. is=false
  691. }else if(this.data.task_cycle==2&&this.data.task_expire_day<=moment().day()){
  692. is=false
  693. }else if(this.data.task_cycle==3&&this.data.task_expire_day<=moment().format('D')){
  694. is=false
  695. }
  696. if (!data.schedule_expire_date) delete data.schedule_expire_date;
  697. this.$axiosUser('post', url, data).then(res => {
  698. if(this.data.task_cycle&&is){
  699. let str=this.data.task_cycle==1? '您发布的每日重复任务将于明天0点执行自动发布,是否需要立即发布一条任务?':this.data.task_cycle==2? '您发布的每周重复任务将于下周一执行自动发布,是否需要立即发布一条任务?':'您发布的每月重复任务将于下个月1号执行自动发布,是否需要立即发布一条任务?'
  700. this.$dialog.confirm({
  701. message: str,
  702. confirmButtonText:'发布',
  703. cancelButtonText:'不需要',
  704. }).then(() => {
  705. this.executeTask(res.data.data)
  706. }).catch(() => {
  707. if (window.plus) {
  708. setTimeout(() => {
  709. plus.navigator.setStatusBarStyle('dark');
  710. document.documentElement.style.backgroundColor = '#fff';
  711. }, 100);
  712. }
  713. this.initData();
  714. localStorage.setItem('callback_data', JSON.stringify({ title: '发布成功', detail_url: '' }));
  715. this.$router.replace({ path: '/callback?replace=1' });
  716. });
  717. }else{
  718. if (window.plus) {
  719. setTimeout(() => {
  720. plus.navigator.setStatusBarStyle('dark');
  721. document.documentElement.style.backgroundColor = '#fff';
  722. }, 100);
  723. }
  724. localStorage.setItem('callback_data', JSON.stringify({ title: '发布成功', detail_url: '' }));
  725. this.$router.replace({ path: '/callback?replace=1' });
  726. }
  727. }).finally(e => {
  728. this.$toast.clear();
  729. });
  730. },
  731. initRuleData(){
  732. this.data.rule_id = 0
  733. this.data.item_id = 0
  734. this.data.rule_item = {
  735. id:0,
  736. remark:"",
  737. cycle_type: 0,
  738. is_attendance: 0,
  739. max_point: 0,
  740. min_point: 0,
  741. prize_type: 0,
  742. pt_id: 0,
  743. range_type: 0,
  744. rule_id: 0,
  745. }
  746. this.data.base_point = 1
  747. this.rule_items = []
  748. this.rules = []
  749. },
  750. initData(){
  751. this.reviewer = [];
  752. this.data = {
  753. task_type: 1,
  754. pt_id: 0,
  755. task_name: '',
  756. task_remark: '',
  757. base_point: 1,
  758. expire_time: '',
  759. file_list: [],
  760. reviewer_id: 0,
  761. timeout_deduction_point: '',
  762. timeout_deduction_point_limit: '',
  763. ahead_award_point: '',
  764. ahead_award_point_limit: '',
  765. dept_ids: [],
  766. task_cycle: 0,
  767. task_expire_day: 1,
  768. schedule_expire_date: ''
  769. };
  770. },
  771. //执行周期任务
  772. executeTask(id){
  773. this.$axiosUser('POST', '/api/pro/integral/schedule/hand_exec',{schedule_id:id}).then(res => {
  774. this.$toast('已发布');
  775. if (window.plus) {
  776. setTimeout(() => {
  777. plus.navigator.setStatusBarStyle('dark');
  778. document.documentElement.style.backgroundColor = '#fff';
  779. }, 100);
  780. }
  781. this.initData();
  782. localStorage.setItem('callback_data', JSON.stringify({ title: '发布成功', detail_url: '' }));
  783. this.$router.replace({ path: '/callback?replace=1' });
  784. });
  785. },
  786. sava_btn() {
  787. // console.log('悬赏 sava_btn',this.data);return;
  788. if (this.data.rule_type === 1 && this.data.rule_id <= 0){
  789. this.$toast.fail ("请选择规则分类")
  790. return
  791. }
  792. if (this.data.rule_type === 2 && this.data.item_id <= 0){
  793. this.$toast.fail('请选择积分规则')
  794. return;
  795. }
  796. if (this.data.base_point <= 0) {
  797. this.$toast.fail('积分必须大于0')
  798. return;
  799. }
  800. let self = this;
  801. self.$validator.validate().then(result => {
  802. if (!result) {
  803. self.$notify({ type: 'danger', message: self.$validator.errors.items[0].msg });
  804. } else {
  805. if (self.data.base_point === 0) {
  806. self.$notify({ type: 'danger', message: '任务积分不能为0' });
  807. } else {
  808. self.sub();
  809. }
  810. }
  811. });
  812. },
  813. scheduleExpireDateConfirm(val) {
  814. this.showScheduleExpireDate = false;
  815. this.scheduleExpireDate = val;
  816. },
  817. clearScheduleExpireDate() {
  818. this.showScheduleExpireDate = false;
  819. this.scheduleExpireDate = null;
  820. }
  821. },
  822. created() {
  823. if (window.plus) {
  824. this.bar_height = window.plus.navigator.getStatusbarHeight();
  825. if(!this.$getCache('flexDialog')){
  826. this.flexDialog=true;
  827. this.$setCache('flexDialog',true);
  828. }
  829. }
  830. }
  831. };
  832. </script>
  833. <style rel="stylesheet/less" lang="less" scoped>
  834. .flexDiaWb{
  835. max-height: 7rem;
  836. overflow-y: auto;
  837. overflow-x: hidden;
  838. margin: 0.4rem 0;
  839. padding: 0 0.2rem 0 0.3rem;
  840. }
  841. /deep/ .van-field__label {
  842. width: 2.4rem;
  843. }
  844. .body_com {
  845. height: calc(100% - 0.92rem);
  846. position: relative;
  847. overflow-y: scroll;
  848. }
  849. .task_move {
  850. margin: 0.32rem;
  851. margin-bottom: 0;
  852. background-color: #fff;
  853. padding: 0.2rem;
  854. .van-row {
  855. .van-col {
  856. position: relative;
  857. text-align: center;
  858. padding: 0.2rem;
  859. font-size: 0.32rem;
  860. padding-left: 0;
  861. padding-right: 0;
  862. .icon {
  863. width: 0.32rem;
  864. height: 0.36rem;
  865. }
  866. &:after {
  867. content: '';
  868. display: block;
  869. height: 0.3rem;
  870. background-color: #dcdfe6;
  871. width: 0.02rem;
  872. clear: both;
  873. right: 0;
  874. position: absolute;
  875. top: 0.3rem;
  876. }
  877. }
  878. }
  879. }
  880. .all_popup {
  881. height: 100vh;
  882. width: 100vw;
  883. background-color: rgb(245, 245, 245);
  884. }
  885. .point_popup_tip {
  886. font-size: 0.24rem;
  887. color: #909399;
  888. line-height: 0.34rem;
  889. background-color: rgb(245, 245, 245);
  890. span {
  891. color: #26a2ff;
  892. }
  893. }
  894. .red {
  895. color: red;
  896. }
  897. .van-popup {
  898. background: rgb(245, 245, 245);
  899. }
  900. .van-col.van-col--8 {
  901. margin-bottom: 0.16rem;
  902. }
  903. /deep/ .depts_cell .van-cell__value {
  904. -webkit-box-flex: unset;
  905. -webkit-flex: none;
  906. flex: none;
  907. width: 4rem !important;
  908. }
  909. /deep/ .van-col.van-col--8 .van-button {
  910. padding: 0;
  911. }
  912. .point-field /deep/ .van-cell__title.van-field__label span {
  913. width: 0;
  914. color: transparent;
  915. height: 0;
  916. overflow: hidden;
  917. font-size: 0;
  918. }
  919. .point-field /deep/ .van-cell__title {
  920. width: 0;
  921. }
  922. .temp_task_box /deep/ .van-icon-close {
  923. color: #238dfa;
  924. padding-top: 0.1rem;
  925. }
  926. .temp_task_box .choose_button {
  927. padding-top: 0.2rem;
  928. background: #fff;
  929. border-radius: 0.08rem;
  930. }
  931. .temp_task_box .choose_button .list {
  932. }
  933. .temp_task_box .choose_button .list /deep/ button {
  934. height: 0.4rem;
  935. margin: 0.16rem auto;
  936. border: none;
  937. border-right: 0.02rem #dcdfe6 solid;
  938. line-height: 0.4rem;
  939. }
  940. .temp_task_box .choose_button .list /deep/ button:hover {
  941. color: #238dfa;
  942. background: transparent;
  943. }
  944. .temp_task_box .choose_button .list /deep/ button:active {
  945. color: #238dfa;
  946. background: transparent;
  947. }
  948. .temp_task_box .choose_button .list /deep/ button:before {
  949. background: transparent;
  950. }
  951. .temp_task_box .choose_button .list:nth-child(3) /deep/ button {
  952. border-right: none;
  953. }
  954. .radio_button /deep/ .changeRadio .van-radio__icon {
  955. background-color: rgba(38, 162, 255, 0.2) !important;
  956. }
  957. .radio_button /deep/.changeRadio .van-radio__icon--checked + .van-radio__label {
  958. color: #26a2ff !important;
  959. }
  960. .temp_task_box .small_tip_content p:nth-child(3) {
  961. display: none;
  962. }
  963. .rule_type_span {
  964. font-size: 0.25rem;
  965. line-height: 0.5rem;
  966. }
  967. </style>