pk.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. <template>
  2. <div>
  3. <!--规则提示-->
  4. <div class="diy_tip_bg" >
  5. <el-alert class="diy-tip" type="success" :closable="false">
  6. <p><b>团队PK通过自定义档案配置、团队参与人员等。在相同积分规则内对团队进行积分对比</b></p>
  7. <p><b>PK配置流程</b></p>
  8. <li class="headLi">指定档案在哪些积分规则分类或者积分规则内有效</li>
  9. <li class="headLi">创建团队,指定参与者</li>
  10. <p><b>团队积分构成</b></p>
  11. <li class="headLi">团队参与者在档案配置中积分规则内的积分总和</li>
  12. <li class="headLi">单独向团队录入的积分</li>
  13. </el-alert>
  14. </div>
  15. <div style="background-color: #fff;padding: 20px;position: relative;" class="flex-box boxMinHeight">
  16. <div class="left box-sizing-w scroll-bar" v-loading="menuLoading">
  17. <div style="text-align: center; padding: 10px 0;">
  18. <el-button type="primary" @click="addDoc" v-if="!manageAble">创建档案</el-button>
  19. </div>
  20. <el-menu v-if="docList.length > 0" :default-active="menuActive" @select="activeRouter" class="el-menu-vertical-demo" >
  21. <el-menu-item v-for="(item, index) in docList" :key="index" :index="index.toString()" @click="refreshContent(item)">
  22. <span slot="title">{{item.name}}</span>
  23. </el-menu-item>
  24. </el-menu>
  25. <div v-if="docList.length == 0"><NoData></NoData></div>
  26. </div>
  27. <div style="overflow-x: auto" class="flex-1 scroll-bar">
  28. <div style="margin-bottom: 20px" >
  29. <el-button v-if="currentDoc" type="primary" size="small" @click="editDoc">档案配置</el-button>
  30. <el-button v-if="currentDoc" type="primary" size="small" @click="addTeam">添加团队</el-button>
  31. </div>
  32. <el-tabs v-if=" currentDoc && currentDoc.teams.length > 0 " v-model="activeTeam" type="border-card" closable @tab-remove="removeTeam" v-loading="contentLoading">
  33. <el-tab-pane v-for="(team,index) in currentDoc.teams" :key="index" :name="index.toString()" :label="team.name" >
  34. <el-table :data="team.employees" v-if="activeTeam == index.toString()"> <!--v-if="activeTeam == index.toString()"防止标签切换抖动-->
  35. <el-table-column label="员工" align="left" width="200">
  36. <template slot-scope="scope">
  37. <userImage class="fl" :id="scope.row.id" :user_name="scope.row.name" :img_url="scope.row.img_url" width="50px" height="50px"></userImage>
  38. <span style="line-height: 50px; padding-left: 10px;">{{ scope.row.name }}</span>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="部门" prop="dept_list" align="center"></el-table-column>
  42. <el-table-column label="操作" align="center">
  43. <template slot="header" slot-scope="scope" >
  44. <el-tooltip effect="light" placement="top" content="团队配置">
  45. <el-button type="primary" size="mini" circle icon="el-icon-setting" @click="editTeam"></el-button>
  46. </el-tooltip>
  47. <el-tooltip effect="light" placement="top" content="添加团队积分">
  48. <el-button type="success" size="mini" circle icon="el-icon-folder-add" @click="addTeamPoint"></el-button>
  49. </el-tooltip>
  50. <el-tooltip effect="light" placement="top" content="团队积分列表">
  51. <el-button type="info" size="mini" circle icon="el-icon-document" @click="clickShowPoint" ></el-button>
  52. </el-tooltip>
  53. <!-- <el-button type="primary" size="mini" round @click="editTeam">团队配置</el-button>-->
  54. <!-- <el-button type="primary" size="mini" round>添加积分</el-button>-->
  55. <!-- <el-button type="primary" size="mini" round>团队积分</el-button>-->
  56. </template>
  57. <template slot-scope="scope">
  58. <el-button @click="dropEmployee(team.id,scope.row.id,scope.row.name)" size="medium" type="danger" >移除出团队</el-button>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. </el-tab-pane>
  63. </el-tabs>
  64. <div v-if="!currentDoc || currentDoc.teams.length === 0"><NoData></NoData></div>
  65. </div>
  66. </div>
  67. <!-- 创建/编辑档案 -->
  68. <el-dialog :title="isUpdateDoc ? '编辑档案': '创建档案' " width="700px" top="10vh" :visible.sync="showDoc" :close-on-click-modal="false" >
  69. <el-form ref="docForm" :model="docForm" :rules="docFormValidateRules" label-width="100px" @submit.native.prevent style="margin: 0 auto;">
  70. <el-form-item label="档案名" prop="name" :required="true">
  71. <el-input v-model="docForm.name" maxlength="10" auto-complete="off" show-word-limit placeholder="请输入档案名" ></el-input>
  72. </el-form-item>
  73. <el-form-item label="积分规则" :required="true" >
  74. <el-select v-model="docForm.ruleType" style="margin-bottom: 6px;width: 400px;" >
  75. <el-option label="全部" :value="1"></el-option>
  76. <el-option label="指定规则分类" :value="2"></el-option>
  77. <el-option label="指定规则" :value="3"></el-option>
  78. </el-select>
  79. <el-cascader
  80. style="width: 400px;"
  81. v-if="docForm.ruleType == 2"
  82. v-model="rule_list_value"
  83. ref="ruleCascader"
  84. :show-all-levels="false"
  85. filterable
  86. :options="rule_list"
  87. :props="{children:'child',label: 'name',value: 'id', checkStrictly: true,multiple: true}"
  88. ></el-cascader>
  89. <div v-if="docForm.ruleType == 3" style="position: relative;" >
  90. <div class="inputBox" @click="showItem = true">
  91. <span v-if="selectItem.length > 0">已选择了{{selectItem.length}}条</span>
  92. <span v-else style="color: #909399;">请选择</span>
  93. </div>
  94. </div>
  95. <div>
  96. <span v-if="docForm.ruleType==1">统计全部积分事件,不包含基础分和工龄分</span>
  97. <span v-if="docForm.ruleType==2">包含指定规则分类的积分,不包含基础分和工龄分</span>
  98. <span v-if="docForm.ruleType==3">按已指定的积分规则进行积分统计并排名,不包含基础分和工龄分</span>
  99. </div>
  100. </el-form-item>
  101. </el-form>
  102. <div class="flex-box-ce">
  103. <el-button type="danger" v-if="isUpdateDoc" :loading="commitLoading" @click="deleteDoc">删 除</el-button>
  104. <div class="flex-1"></div>
  105. <el-button type="primary" :loading="commitLoading" @click="commitDocForm('docForm')" >提 交</el-button>
  106. </div>
  107. </el-dialog>
  108. <!-- 创建编辑团队 -->
  109. <el-dialog :title="isUpdateTeam ? '编辑团队' : '创建团队'" width="700px" top="10vh" :visible.sync="showTeam" :close-on-click-modal="false" >
  110. <el-form ref="teamForm" :model="teamForm" :rules="teamFormValidateRules" label-width="100px" @submit.native.prevent style="margin: 0 auto;" >
  111. <el-form-item label="团队名" prop="name" :required="true">
  112. <el-input v-model="teamForm.name" maxlength="10" auto-complete="off" show-word-limit placeholder="请输入团队名" ></el-input>
  113. </el-form-item>
  114. <el-form-item label="参与人员" :required="true">
  115. <div class="cursor" style="border-radius: 4px;border: 1px solid #dcdfe6;line-height: 34px;width: 400px;padding: 0 15px;" @click="showEmployeeSelect">
  116. <div class="flex-box-ce fontColorB font-flex-word" v-if="employees_selected.employee.length>0">
  117. <span v-for="item in employees_selected.employee" :key="item.id"> {{item.name}},</span>
  118. </div>
  119. <div v-else style="color: #C0C4CF;">请选择参与人员</div>
  120. </div>
  121. </el-form-item>
  122. </el-form>
  123. <div class="flex-box-ce">
  124. <el-button type="danger" v-if="isUpdateTeam" :loading="commitLoading" @click="deleteTeam">删 除</el-button>
  125. <div class="flex-1"></div>
  126. <el-button type="primary" :loading="commitLoading" @click="commitTeamForm('teamForm')" >提 交</el-button>
  127. </div>
  128. </el-dialog>
  129. <!-- 添加团队积分 -->
  130. <el-dialog title="添加团队积分" width="700px" top="10vh" :visible.sync="showAddPoint" :close-on-click-modal="false" >
  131. <el-form ref="pointForm" :model="pointForm" :rules="pointFormValidateRules" label-width="100px" @submit.native.prevent style="margin: 0 auto;">
  132. <el-form-item label="积分" prop="point" :required="true">
  133. <el-input-number v-model="pointForm.point" :min="-999999" :max="999999" ></el-input-number>
  134. </el-form-item>
  135. <el-form-item label="日期" prop="date" :required="true">
  136. <el-date-picker
  137. v-model="pointForm.date"
  138. type="date"
  139. value-format="yyyy-MM-dd"
  140. ></el-date-picker>
  141. </el-form-item>
  142. <el-form-item label="说明" prop="remark" >
  143. <el-input
  144. placeholder="积分说明"
  145. type="textarea"
  146. v-model="pointForm.remark"
  147. maxlength="100"
  148. rows="4"
  149. show-word-limit
  150. clearable></el-input>
  151. </el-form-item>
  152. <div class="flex-box-ce">
  153. <div class="flex-1"></div>
  154. <el-button type="primary" :loading="commitLoading" @click="commitPointForm('pointForm')" >提 交</el-button>
  155. </div>
  156. </el-form>
  157. </el-dialog>
  158. <el-dialog title="团队积分事件" width="700px" top="10vh" :visible.sync="showPoint" :close-on-click-modal="false" >
  159. <el-form :inline="true" @submit.native.prevent >
  160. <el-date-picker
  161. v-model="pointSearchDateScope"
  162. type="daterange"
  163. align="right"
  164. unlink-panels
  165. range-separator="至"
  166. start-placeholder="开始日期"
  167. end-placeholder="结束日期"
  168. value-format="yyyy-MM-dd"
  169. editable
  170. ></el-date-picker>
  171. </el-form>
  172. <el-table :data="pointListData.list" style="width: 100%" v-loading="pointListLoading" >
  173. <el-table-column label="积分" align="center" prop="point"></el-table-column>
  174. <el-table-column label="日期" align="center" prop="date"></el-table-column>
  175. <el-table-column label="说明" align="center" prop="remark"></el-table-column>
  176. <template slot="empty">
  177. <NoData></NoData>
  178. </template>
  179. </el-table>
  180. <el-pagination
  181. @current-change="handlePointPageChange"
  182. :current-page="pointSearchForm.page"
  183. :page-size="pointSearchForm.pageSize"
  184. :total="pointListData.total"
  185. ></el-pagination>
  186. </el-dialog>
  187. <EmployeeSelector
  188. title="选择成员"
  189. :selected="employees_selected"
  190. :close_clear_data="false"
  191. :visible.sync="showEmployeeSelector"
  192. @confirm="move_employee_confirm"
  193. :isChecKedAll="true"
  194. :max="0"
  195. />
  196. <SelectRule :isAll="true" :visible.sync="showItem" @confirm="ruleConfirm" :ptId="docForm.ptId" :selectItems="selectItem"></SelectRule>
  197. </div>
  198. </template>
  199. <script>
  200. import SelectRule from "@/components/SelectRule.vue";
  201. import EmployeeSelector from "@/components/EmployeeSelector.vue";
  202. import Template from "../../../examine/components/Template.vue";
  203. export default {
  204. components: {Template, SelectRule,EmployeeSelector},
  205. data(){
  206. return {
  207. manageAble: this.$supremeAuthority('dept_manager') || this.$supremeAuthority('employee'),
  208. menuActive: '0',
  209. menuLoading: false,
  210. contentLoading: false,
  211. currentDoc: null,
  212. currentTeam: null,
  213. activeTeam: 0,
  214. docList: [],
  215. isUpdateDoc: false,
  216. isUpdateTeam: false,
  217. showDoc: false,
  218. showTeam: false,
  219. showEmployeeSelector: false,
  220. docForm:{
  221. docId:0,
  222. name:'',
  223. ptId:3,
  224. ruleType:1,
  225. rules:[],
  226. items:[],
  227. },
  228. docFormValidateRules:{
  229. name: [
  230. {required: true,message:'请输入档案名称'},
  231. { min: 3, max: 10, message: '长度在 3 到 10 个字符'}
  232. ]
  233. },
  234. teamFormValidateRules:{
  235. name: [
  236. {required: true,message:'请输入档案名称'},
  237. { min: 3, max: 10, message: '长度在 3 到 10 个字符'}
  238. ]
  239. },
  240. // 规则分类
  241. rule_list: [],
  242. rule_tree:[],
  243. rule_list_value:[],
  244. showItem:false,
  245. selectItem:[],
  246. commitLoading:false,
  247. teamForm:{
  248. docId:0,
  249. teamId:0,
  250. name:"",
  251. employees:[]
  252. },
  253. employees_selected: { employee: [], dept: [] },
  254. showAddPoint:false,
  255. showPoint:false,
  256. pointForm:{
  257. teamId:0,
  258. teamName:'',
  259. point:0,
  260. date:"",
  261. remark:""
  262. },
  263. pointFormValidateRules:{
  264. point:[
  265. {type:'integer'},
  266. {required:true,message:"必须填写积分"},
  267. ],
  268. remark:[
  269. {type:'string'},
  270. {min:0,max:100,message:"最多100个字符"}
  271. ],
  272. date:[
  273. {type:'string'},
  274. {required:true,message:'积分日期必须填写'}
  275. ]
  276. },
  277. pointSearchDateScope:[],
  278. pointSearchForm:{
  279. timeScope:[],
  280. teamId:0,
  281. docId:0,
  282. page:1,
  283. pageSize:10
  284. },
  285. pointListLoading:false,
  286. pointListData:{
  287. list:[],
  288. total:0
  289. }
  290. }
  291. },
  292. methods: {
  293. initDocForm(){
  294. this.docForm.docId = 0;
  295. this.docForm.name = '';
  296. this.docForm.ruletype = 1;
  297. this.docForm.rules = [];
  298. this.docForm.items = [];
  299. this.selectItem = [];
  300. this.rule_list_value = [];
  301. },
  302. initTeamForm(){
  303. this.teamForm.docId = this.currentDoc.id;
  304. this.teamForm.teamId = 0;
  305. this.teamForm.name = '';
  306. this.teamForm.employees = [];
  307. this.employees_selected = { employee: [], dept: [] };
  308. },
  309. initPointForm(){
  310. this.pointForm.teamName = '';
  311. this.pointForm.point = 0;
  312. this.pointForm.teamId = 0;
  313. this.pointForm.remark = '';
  314. this.pointForm.date = '';
  315. },
  316. initPointListData(){
  317. this.pointListData = {
  318. list:[],
  319. total:0
  320. }
  321. },
  322. addDoc(){
  323. //封装表单数据
  324. this.initDocForm()
  325. //打开表单弹窗
  326. this.isUpdateDoc = false;
  327. this.showDoc = true;
  328. },
  329. editDoc(){
  330. //封装表单数据
  331. this.docForm.docId = this.currentDoc.id;
  332. this.docForm.name = this.currentDoc.name;
  333. if (this.currentDoc.items.length > 0){
  334. this.docForm.ruleType = 3;
  335. this.docForm.rules = [];
  336. this.docForm.items = this.currentDoc.items.map(e => e.id)
  337. this.selectItem = this.currentDoc.items.map(e => {
  338. return {
  339. id:e.id,
  340. remark:e.name
  341. }
  342. })
  343. }else if (this.currentDoc.rules.length > 0){
  344. this.docForm.ruleType = 2;
  345. this.docForm.items = [];
  346. this.docForm.rules = this.currentDoc.rules.map(e => e.id)
  347. let rule_list_value = [];
  348. if(this.currentDoc.rules.length > 0){
  349. this.docForm.rules.forEach(id => {
  350. let arr = [];
  351. this.returnRuleVal(id,arr);
  352. rule_list_value.push(arr);
  353. this.rule_list_value = rule_list_value;
  354. })
  355. }
  356. }else {
  357. this.docForm.ruleType = 1;
  358. this.docForm.rules = [];
  359. this.docForm.rules = [];
  360. this.selectItem = [];
  361. this.rule_list_value = [];
  362. }
  363. //打开表单弹窗
  364. this.isUpdateDoc = true;
  365. this.showDoc = true;
  366. },
  367. deleteDoc(){
  368. this.$confirm('确认删除当前档案吗?','删除档案',{confirmButtonText:'确定',cancelButtonText:'取消',type:"warning"}).then(() => {
  369. this.commitDeleteDoc();
  370. })
  371. },
  372. getDocList(){
  373. this.menuLoading = true;
  374. this.$axiosUser('get','/api/pro/pk/doc/list').then(res => {
  375. this.docList = res.data.data.list;
  376. if(this.docList.length > 0 && !this.currentDoc){
  377. this.refreshContent(this.docList[this.menuActive]);
  378. }
  379. }).finally(()=>{
  380. this.menuLoading = false;
  381. })
  382. },
  383. //获取分类规则
  384. get_rule_trees() {
  385. let params = {pt_id:3,cycle_type:1};
  386. this.$axiosUser('get', '/api/pro/integral/rule/trees', params).then(res => {
  387. this.rule_list = this.getTreeData(res.data.data.rule_tree);
  388. this.rule_tree = this.flatten(res.data.data.rule_tree);
  389. })
  390. },
  391. // 递归判断列表,把最后的child设为undefined
  392. getTreeData(data) {
  393. for (var i = 0; i < data.length; i++) {
  394. if (data[i].child.length < 1) {
  395. // child若为空数组,则将child设为undefined
  396. data[i].child = undefined;
  397. } else {
  398. // child若不为空数组,则继续 递归调用 本方法
  399. this.getTreeData(data[i].child);
  400. }
  401. }
  402. return data;
  403. },
  404. flatten(arr) {
  405. return arr.reduce((result, item) => {
  406. return result.concat(item, Array.isArray(item.child) ? this.flatten(item.child) : []);
  407. }, []);
  408. },
  409. returnRuleVal(rule_id,arr){
  410. arr.unshift(rule_id)
  411. let list = this.rule_tree.filter(x => x.id == rule_id)
  412. if(list[0]&&list[0].pid != 0){
  413. this.returnRuleVal(list[0].pid,arr)
  414. }
  415. return arr;
  416. },
  417. activeRouter(index, indexPath){
  418. this.menuActive = index.toString();
  419. },
  420. //加载右边内容页
  421. refreshContent(doc){
  422. if (!doc || !doc.id) return;
  423. this.currentTeam = null;
  424. this.currentDoc = null;
  425. this.contentLoading = true;
  426. this.$axiosUser('get','/api/pro/pk/doc/info',{doc_id:doc.id})
  427. .then(res => {
  428. this.currentDoc = res.data.data;
  429. this.activeTeam = 0; //只能在这里设置不能在开头初始化
  430. if (this.currentDoc.teams.length > 0) this.currentTeam = this.currentDoc.teams[0];
  431. })
  432. .finally(() => {
  433. this.contentLoading = false;
  434. })
  435. },
  436. addTeam(){
  437. //封装表单数据
  438. this.initTeamForm();
  439. //打开表单弹窗
  440. this.isUpdateTeam = false;
  441. this.showTeam = true;
  442. },
  443. editTeam(){
  444. //封装表单数据
  445. this.teamForm.docId = this.currentDoc.id;
  446. this.teamForm.teamId = this.currentTeam.id;
  447. this.teamForm.name = this.currentTeam.name;
  448. this.teamForm.employees = this.currentTeam.employees.map(e => e.id);
  449. this.employees_selected.employee = this.currentTeam.employees;
  450. //打开表单弹窗
  451. this.isUpdateTeam = true;
  452. this.showTeam = true;
  453. },
  454. deleteTeam(){
  455. this.$confirm('确认删除当前团队吗?','删除团队',{
  456. confirmButtonText: '确定',
  457. cancelButtonText: '取消',
  458. type: 'warning'
  459. }).then(() => {
  460. this.commitDeleteTeam(this.teamForm.teamId);
  461. })
  462. },
  463. removeTeam(i){
  464. if (this.currentDoc.teams.length < i) return;
  465. let team = this.currentDoc.teams[i];
  466. let message = '确认删除团队<<' + team.name + '>>吗?';
  467. this.$confirm(message,'删除团队',{
  468. confirmButtonText: '确定',
  469. cancelButtonText: '取消',
  470. type: 'warning'
  471. }).then(() => {
  472. this.commitDeleteTeam(team.id)
  473. })
  474. },
  475. commitDeleteTeam(teamId){
  476. this.commitLoading = true;
  477. this.$axiosUser('POST','/api/pro/pk/team/d',{team_id:teamId})
  478. .then(res => {
  479. this.$message.success(res.data.msg);
  480. this.isUpdateTeam = false;
  481. this.showTeam = false;
  482. this.initTeamForm();
  483. this.refreshContent(this.currentDoc);
  484. })
  485. .finally(() => {
  486. this.commitLoading = false;
  487. })
  488. },
  489. dropEmployee(teamId,employeeId,employeeName){
  490. let message = "确认将<<" + employeeName + ">>移出团队吗?"
  491. this.$confirm(message,"移出团队",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"})
  492. .then(() => {
  493. this.commitDeleteEmployee(teamId,employeeId);
  494. })
  495. },
  496. //选择规则
  497. ruleConfirm(rules) {
  498. if (rules.length > 0) {
  499. this.docForm.items = rules.map(e=> e.id);
  500. } else {
  501. this.docForm.items = [];
  502. }
  503. this.selectItem = rules;
  504. },
  505. commitDocForm(formName) {
  506. this.$refs[formName].validate(valid => {
  507. if (!valid) return;
  508. if (this.isUpdateDoc){
  509. this.commitUpdateDoc();
  510. }else{
  511. this.commitCreateDoc();
  512. }
  513. })
  514. },
  515. commitCreateDoc(){
  516. let params = {
  517. name:this.docForm.name,
  518. rules:[],
  519. items:[]
  520. };
  521. if (this.docForm.docId > 0){
  522. this.$message.error("表单状态异常");
  523. return;
  524. }
  525. if(this.docForm.ruleType === 2) {
  526. if (this.docForm.rules.length === 0){
  527. this.$message.error("选择规则分类");
  528. return;
  529. }
  530. params.rules = this.docForm.rules;
  531. }else if(this.docForm.ruleType === 3){
  532. if (this.docForm.items.length === 0){
  533. this.$message.error("请选择规则");
  534. return;
  535. }
  536. params.items = this.docForm.items;
  537. }
  538. this.commitLoading = true
  539. this.$axiosUser('POST','/api/pro/pk/doc/c',params).then(res => {
  540. this.$message.success(res.data.msg);
  541. this.showDoc = false;
  542. this.initDocForm();
  543. this.getDocList();
  544. })
  545. .finally(() => {
  546. this.commitLoading = false
  547. });
  548. },
  549. commitUpdateDoc(){
  550. let params = {
  551. doc_id:this.docForm.docId,
  552. name:this.docForm.name,
  553. rules:[],
  554. items:[]
  555. }
  556. if (this.docForm.docId <= 0){
  557. this.$message.error("表单状态异常");
  558. return;
  559. }
  560. if(this.docForm.ruleType === 2) {
  561. if (this.docForm.rules.length === 0){
  562. this.$message.error("选择规则分类");
  563. return;
  564. }
  565. params.rules = this.docForm.rules;
  566. }else if(this.docForm.ruleType === 3){
  567. if (this.docForm.items.length === 0){
  568. this.$message.error("请选择规则");
  569. return;
  570. }
  571. params.items = this.docForm.items;
  572. }
  573. this.commitLoading = true
  574. this.$axiosUser('POST','/api/pro/pk/doc/e',params).then(res => {
  575. this.$message.success(res.data.msg);
  576. this.showDoc = false;
  577. this.initDocForm();
  578. this.getDocList();
  579. })
  580. .finally(() => {
  581. this.commitLoading = false
  582. });
  583. },
  584. // 选人组件提交
  585. move_employee_confirm(data) {
  586. this.teamForm.employees = data.employee.map(element => {
  587. return element.id
  588. });
  589. this.employees_selected.employee = data.employee;
  590. },
  591. showEmployeeSelect(){
  592. this.showEmployeeSelector = true;
  593. },
  594. commitTeamForm(formName){
  595. this.$refs[formName].validate(valid => {
  596. if (!valid) return;
  597. if (this.isUpdateTeam){
  598. this.commitUpdateTeam();
  599. }else {
  600. this.commitCreateTeam();
  601. }
  602. })
  603. },
  604. commitUpdateTeam(){
  605. let params = {
  606. team_id:this.teamForm.teamId,
  607. name:this.teamForm.name,
  608. employees:this.teamForm.employees
  609. }
  610. this.commitLoading = true;
  611. this.$axiosUser('POST','/api/pro/pk/team/e',params).then(res => {
  612. this.$message.success(res.data.msg);
  613. this.showTeam = false;
  614. this.initTeamForm();
  615. this.refreshContent(this.currentDoc)
  616. })
  617. .finally(() => {
  618. this.commitLoading = false
  619. });
  620. },
  621. commitCreateTeam(){
  622. let params = {
  623. doc_id: this.teamForm.docId,
  624. name: this.teamForm.name,
  625. employees:this.teamForm.employees
  626. }
  627. this.$axiosUser('POST','/api/pro/pk/team/c',params).then(res => {
  628. this.$message.success(res.data.msg);
  629. this.showTeam = false;
  630. this.initTeamForm();
  631. this.refreshContent(this.currentDoc)
  632. })
  633. .finally(() =>{
  634. this.commitLoading = false
  635. });
  636. },
  637. commitDeleteEmployee(teamId,employeeId){
  638. this.commitLoading = true;
  639. this.$axiosUser('POST','/api/pro/pk/team/employee/d',{team_id:teamId,employee_id:employeeId})
  640. .then(res => {
  641. this.$message.success(res.data.msg);
  642. this.refreshContent(this.currentDoc);
  643. })
  644. .finally(()=>{
  645. this.commitLoading = false
  646. })
  647. },
  648. commitDeleteDoc(){
  649. this.commitLoading = true;
  650. this.$axiosUser('POST','/api/pro/pk/doc/d',{doc_id:this.currentDoc.id})
  651. .then(res => {
  652. this.$message.success(res.data.msg);
  653. this.showDoc = false;
  654. this.currentDoc = null;
  655. this.currentTeam = null;
  656. this.initDocForm();
  657. this.getDocList();
  658. })
  659. .finally(() => {
  660. this.commitLoading = false;
  661. })
  662. },
  663. addTeamPoint(){
  664. this.pointForm.teamId = this.currentTeam.id;
  665. this.pointForm.teamName = this.currentTeam.name;
  666. this.showAddPoint = true;
  667. this.pointForm.date = this.$moment(new Date()).format('YYYY-MM-DD');
  668. },
  669. commitPointForm(formName){
  670. this.$refs[formName].validate(valid => {
  671. if (!valid) return;
  672. this.commitLoading = true;
  673. let params = {
  674. team_id: this.pointForm.teamId,
  675. point: this.pointForm.point,
  676. date: this.pointForm.date,
  677. remark: this.pointForm.remark
  678. }
  679. this.$axiosUser('POST','/api/pro/pk/team/point',params)
  680. .then(res => {
  681. this.$message.success(res.data.msg);
  682. this.showAddPoint = false;
  683. this.initPointForm();
  684. })
  685. .finally(()=>{
  686. this.commitLoading = false;
  687. })
  688. })
  689. },
  690. initPointSearchDateRange(){
  691. //初始化积分列表时间区间
  692. const pkStartData = new Date();
  693. const pkEndData = new Date();
  694. pkStartData.setTime(pkStartData.getTime() - 3600 * 1000 * 24 * 30);
  695. this.pointSearchDateScope[0] = this.$moment(pkStartData).format('YYYY-MM-DD');
  696. this.pointSearchDateScope[1] = this.$moment(pkEndData).format('YYYY-MM-DD');
  697. this.pointSearchForm.timeScope = this.pointSearchDateScope;
  698. },
  699. initPointSearchForm(){
  700. this.initPointSearchDateRange();
  701. this.pointSearchForm.teamId = this.currentTeam.id;
  702. this.pointSearchForm.docId = this.currentDoc.id;
  703. this.pointSearchForm.page = 1;
  704. this.pointSearchForm.pageSize = 10;
  705. },
  706. handlePointPageChange(page){
  707. this.pointSearchForm.page = page;
  708. this.getPointList();
  709. },
  710. getPointList(){
  711. if (this.pointSearchForm.teamId === 0 || this.pointSearchForm.docId === 0 || !this.pointSearchForm.timeScope || this.pointSearchForm.timeScope.length !== 2) {
  712. this.initPointListData();
  713. return;
  714. }
  715. this.pointListLoading = true;
  716. let params = {
  717. doc_id: this.pointSearchForm.docId,
  718. team_id: this.pointSearchForm.teamId,
  719. page: this.pointSearchForm.page,
  720. page_size: this.pointSearchForm.pageSize,
  721. start_date: this.pointSearchForm.timeScope[0],
  722. end_date: this.pointSearchForm.timeScope[1]
  723. }
  724. this.$axiosUser('get','/api/pro/pk/team/point/list',params)
  725. .then(res => {
  726. this.pointListData = res.data.data;
  727. })
  728. .finally(()=>{
  729. this.pointListLoading = false;
  730. })
  731. },
  732. clickShowPoint(){
  733. //初始化积分搜索数据
  734. this.initPointSearchForm();
  735. this.getPointList();
  736. this.showPoint = true;
  737. }
  738. },
  739. created() {
  740. this.get_rule_trees();
  741. },
  742. watch:{
  743. activeTeam(value){
  744. this.currentTeam = this.currentDoc.teams.length > value ? this.currentDoc.teams[value] : null;
  745. },
  746. rule_list_value(val){
  747. if(val.length > 0){
  748. this.docForm.rules = val.map(e => e[e.length - 1]);
  749. }else {
  750. this.docForm.rules = [];
  751. }
  752. },
  753. pointSearchDateScope(val){
  754. this.pointSearchForm.timeScope = val ? val : [];
  755. this.getPointList();
  756. }
  757. },
  758. mounted() {
  759. this.getDocList();
  760. }
  761. }
  762. </script>
  763. <style scoped lang="scss">
  764. .diy_tip_bg {
  765. background: #f5f6f9;
  766. overflow: hidden;
  767. .diy-tip {
  768. margin-bottom: 10px;
  769. border: 1px solid #67c23a;
  770. padding: 20px 16px;
  771. p {
  772. color: #67c23a !important;
  773. font-size: 15px;
  774. margin: 0 !important;
  775. padding-bottom: 4px;
  776. }
  777. }
  778. }
  779. .headLi {
  780. padding: 4px;
  781. list-style: disc;
  782. font-size: 14px;
  783. }
  784. .left{
  785. padding:10px;
  786. overflow: auto;
  787. max-height: 800px;
  788. }
  789. .boxMinHeight{
  790. background-color: #fff;
  791. }
  792. .inputBox {
  793. height: 36px;
  794. line-height: 36px;
  795. padding-right: 30px;
  796. -webkit-appearance: none;
  797. background-color: #fff;
  798. background-image: none;
  799. border-radius: 4px;
  800. border: 1px solid #dcdfe6;
  801. -webkit-box-sizing: border-box;
  802. box-sizing: border-box;
  803. color: #606266;
  804. display: inline-block;
  805. font-size: inherit;
  806. width: 400px;
  807. outline: 0;
  808. padding: 0 15px;
  809. cursor: pointer;
  810. -webkit-transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  811. transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  812. }
  813. </style>