recallMuban.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <div class="container" v-loading="loading">
  3. <fullscreen :fullscreen.sync="fullscreen" class="container-box">
  4. <div class="titbox">
  5. <h2 class="font-ui">科室绩效回复</h2>
  6. <div>
  7. <i class="el-icon-refresh" @click="iconCli(1)"></i>
  8. <i class="el-icon-full-screen" @click="iconCli(2)"></i>
  9. </div>
  10. </div>
  11. <div style="height: 100%">
  12. <div style="overflow: none">
  13. <el-date-picker v-model="monthValue" @change="checkMonth" value-format="yyyy-MM" type="month"
  14. placeholder="选择月">
  15. </el-date-picker>
  16. <el-select v-model="value" @change="checkDecpt" clearable placeholder="请选择部门">
  17. <el-option v-for="item in options" :key="item.receiveName" :label="item.receiveDeptName"
  18. :value="item.receiveDeptCode">
  19. </el-option>
  20. </el-select>
  21. <div style="float: right">
  22. <el-button v-if="dataBody.task.sts == '0' && dataBody.rows.length > 0" size="small"
  23. @click="submit" type="primary">回复</el-button>
  24. <el-button v-if="dataBody.task.sts == '0' && dataBody.rows.length > 0" size="small"
  25. @click="save" type="primary">保存</el-button>
  26. <el-button v-if="dataBody.rows.length > 0" size="small" type="primary" @click="exportExcel">导出
  27. </el-button>
  28. <el-button size="small" @click="goBack" type="primary">返回</el-button>
  29. </div>
  30. <!-- <el-upload
  31. v-if="dataBody.task.sts == '0'"
  32. :disabled="value == '' ? true : false"
  33. style="float: right"
  34. class="upload-demo"
  35. action="http://192.168.2.170:9600/spfm/market/kpitemps/addTemp"
  36. :before-remove="beforeRemove"
  37. :before-upload="beforeUploadForm"
  38. :http-request="fileChange"
  39. :show-file-list="false"
  40. :file-list="fileList"
  41. >
  42. <el-button
  43. v-if="dataBody.task.sts == '0'"
  44. size="small"
  45. @click="isDisabled"
  46. type="primary"
  47. >点击上传</el-button
  48. >
  49. </el-upload> -->
  50. </div>
  51. <div v-if="dataBody.rows.length > 0" id="tabbox">
  52. <div style="width: 30%; margin: 15px auto">
  53. <el-input readonly v-model="dataBody.table.tabName"></el-input>
  54. </div>
  55. <table class="dataBody-box" border-collapse="collapse" border="1">
  56. <tbody>
  57. <tr v-for="(item, index) in dataBody.rows" :key="index">
  58. <td @contextmenu="showMenu(index, zindex)" class="cell" v-for="(row, zindex) in item"
  59. :key="zindex" :rowspan="row.rowSpan" :colspan="row.colSpan"
  60. v-show="row.displayFlag == '0'">
  61. <div v-show="false">
  62. {{ (dataBody.rows[index][zindex].colNum = zindex) }}
  63. {{ (dataBody.rows[index][zindex].rowNum = index) }}
  64. </div>
  65. <el-input :disabled="dataBody.task.sts != '0'" class="table-input"
  66. v-model="row.cellVal"></el-input>
  67. </td>
  68. </tr>
  69. </tbody>
  70. </table>
  71. </div>
  72. <div class="center-style" v-else>请选择需要查看的绩效</div>
  73. </div>
  74. <vue-context-menu :contextMenuData="contextMenuData" @deleteHang="deleteHang" @addHangUp="addHangUp">
  75. </vue-context-menu>
  76. </fullscreen>
  77. </div>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. disabled: true,
  84. options: [],
  85. value: "",
  86. monthValue: "",
  87. cellWidth: {
  88. width: "auto"
  89. },
  90. isMove: false,
  91. autoStyle: {},
  92. xindex: "",
  93. yindex: "",
  94. dataBody: {
  95. rows: [],
  96. table: {
  97. opName: "",
  98. opNo: "",
  99. opTime: "",
  100. opTimeFrom: "",
  101. opTimeTo: "",
  102. tabCode: "",
  103. tabCodePks: "",
  104. tabName: "",
  105. },
  106. task: {
  107. sts: 1,
  108. },
  109. },
  110. contextMenuData: {
  111. menuName: "demo",
  112. //菜单显示的位置
  113. axis: {
  114. x: null,
  115. y: null,
  116. },
  117. //菜单选项
  118. menulists: [{
  119. fnHandler: "deleteHang", //绑定事件
  120. btnName: "删除行", //菜单名称
  121. },
  122. {
  123. fnHandler: "addHangUp", //绑定事件
  124. btnName: "插入行", //菜单名称
  125. },
  126. ],
  127. },
  128. hangIndex: "",
  129. lieIndex: "",
  130. fullscreen: false,
  131. loading: false,
  132. fileList: [],
  133. };
  134. },
  135. methods: {
  136. isDisabled() {
  137. if (this.value == "") {
  138. this.$message({
  139. message: "请先选择部门!",
  140. type: "warning",
  141. });
  142. return false;
  143. }
  144. },
  145. // 回复
  146. submit() {
  147. this.loading = true;
  148. this.$http({
  149. url: "/market/kpidepts/saveInfo",
  150. method: "post",
  151. headers: {
  152. "Content-Type": "application/json",
  153. },
  154. data: this.dataBody,
  155. }).then((res) => {
  156. if (res.data.result == 0) {
  157. this.$message({
  158. message: "回复成功",
  159. type: "success",
  160. });
  161. this.getInitData(this.value);
  162. }
  163. this.loading = false;
  164. });
  165. },
  166. beforeUploadForm(file) {
  167. // 验证文件类型
  168. var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
  169. const extension = testmsg === "xlsx";
  170. if (!extension) {
  171. this.$message({
  172. message: "上传文件只能是excel格式!",
  173. duration: 1000,
  174. showClose: true,
  175. type: "warning",
  176. });
  177. return false;
  178. }
  179. },
  180. // 提交文件
  181. fileChange(param, type) {
  182. let formData = new FormData();
  183. formData.append("file", param.file);
  184. formData.append("tabCode", "");
  185. this.loading = true;
  186. this.$http({
  187. url: "/market/kpitemps/addTemp",
  188. method: "post",
  189. headers: {
  190. "Content-Type": "application/json",
  191. },
  192. data: formData,
  193. })
  194. .then((res) => {
  195. if (res.data.result == 0) {
  196. this.closeMenu = true;
  197. this.$message({
  198. message: "上传成功",
  199. type: "success",
  200. });
  201. this.dataBody = res.data.body;
  202. this.$forceUpdate();
  203. }
  204. this.loading = false;
  205. })
  206. .catch((err) => {
  207. this.loading = false;
  208. });
  209. },
  210. beforeRemove(file, fileList) {
  211. // return this.$confirm(`确定移除 ${file.name}?`);
  212. },
  213. exportExcel() {
  214. this.$http({
  215. url: "/market/kpidepts/downloadKpi",
  216. method: "get",
  217. headers: {
  218. "Content-Type": "application/json",
  219. },
  220. responseType: "blob",
  221. params: {
  222. tabInstId: this.dataBody.tabInstId
  223. },
  224. }).then((response) => {
  225. if (window.navigator && window.navigator.msSaveOrOpenBlob) {
  226. let blob = new Blob([response.data], {
  227. type: "application/vnd.ms-excel",
  228. });
  229. window.navigator.msSaveOrOpenBlob(
  230. blob,
  231. this.dataBody.table.tabName + ".xlsx"
  232. );
  233. } else {
  234. /* 火狐谷歌的文件下载方式 */
  235. var blob = new Blob([response.data]);
  236. var downloadElement = document.createElement("a");
  237. var href = window.URL.createObjectURL(blob);
  238. downloadElement.href = href;
  239. downloadElement.download = this.dataBody.table.tabName + ".xlsx";
  240. document.body.appendChild(downloadElement);
  241. downloadElement.click();
  242. document.body.removeChild(downloadElement);
  243. window.URL.revokeObjectURL(href);
  244. }
  245. });
  246. },
  247. imports() {},
  248. checkDecpt(val) {
  249. if (val == "") {
  250. this.dataBody.rows = [];
  251. } else {
  252. this.getInitData(val);
  253. }
  254. },
  255. checkMonth(val) {
  256. this.$http({
  257. url: "/market/kpidepts/loadReceiver",
  258. method: "post",
  259. headers: {
  260. "Content-Type": "application/json",
  261. },
  262. data: {
  263. kpiMonth: val
  264. },
  265. }).then((res) => {
  266. if (res.data.result == 0) {
  267. this.options = res.data.body;
  268. if (res.data.body.length > 0) {
  269. this.value = res.data.body[0].receiveDeptCode;
  270. this.getInitData(res.data.body[0].receiveDeptCode);
  271. } else {
  272. this.value = "";
  273. this.dataBody.rows = [];
  274. }
  275. } else {
  276. this.value = "";
  277. this.dataBody.rows = [];
  278. }
  279. });
  280. },
  281. goBack() {
  282. this.$router.push("/leader");
  283. },
  284. //功能栏
  285. iconCli(v) {
  286. if (v === 1) {
  287. this.getList(this.params, this.pageSize);
  288. }
  289. if (v === 2) {
  290. this.fullscreen = !this.fullscreen;
  291. }
  292. },
  293. showMenu(index, zindex) {
  294. this.hangIndex = index;
  295. this.lieIndex = zindex;
  296. event.preventDefault();
  297. var x = event.clientX;
  298. var y = event.clientY;
  299. // Get the current location
  300. this.contextMenuData.axis = {
  301. x,
  302. y,
  303. };
  304. },
  305. // 保存
  306. save() {
  307. this.loading = true;
  308. this.$http({
  309. url: "/market/kpidepts/save",
  310. method: "post",
  311. headers: {
  312. "Content-Type": "application/json",
  313. },
  314. data: this.dataBody,
  315. }).then((res) => {
  316. if (res.data.result == 0) {
  317. this.loading = false;
  318. this.$message({
  319. message: "操作成功",
  320. type: "success",
  321. });
  322. }
  323. });
  324. },
  325. // 向上增加行
  326. addHangUp() {
  327. let itemArr = [];
  328. for (let i = 0; i < this.hangIndex; i++) {
  329. this.dataBody.rows[i].map((item) => {
  330. if (
  331. this.hangIndex <= parseInt(item.rowSpan) + i - 1 &&
  332. parseInt(item.rowSpan) > 1
  333. ) {
  334. item.rowSpan = parseInt(item.rowSpan) + 1;
  335. }
  336. });
  337. }
  338. itemArr = JSON.parse(JSON.stringify(this.dataBody.rows[this.hangIndex]));
  339. itemArr.map((item) => {
  340. item.rowSpan = "1";
  341. item.cellVal = "";
  342. });
  343. this.dataBody.rows.splice(this.hangIndex, 0, itemArr);
  344. },
  345. // 删除行
  346. deleteHang() {
  347. if (
  348. parseInt(this.dataBody.rows[this.hangIndex][this.lieIndex].rowSpan) > 1
  349. ) {
  350. this.$message({
  351. message: "当前行有合并项不能删除",
  352. type: "wanrning",
  353. });
  354. return;
  355. }
  356. let num = 0;
  357. this.dataBody.rows[this.hangIndex].map((item, index) => {
  358. if (parseInt(item.rowSpan) > 1) {
  359. this.dataBody.rows[parseInt(this.hangIndex) + 1][index].displayFlag =
  360. "0";
  361. this.dataBody.rows[parseInt(this.hangIndex) + 1][index].rowSpan =
  362. parseInt(item.rowSpan) - 1;
  363. } else if (item.displayFlag == "1") {
  364. for (let i = this.hangIndex; i >= 0; i--) {
  365. num = 0;
  366. this.dataBody.rows[i].map((item, zindex) => {
  367. if (item.displayFlag == "0") {
  368. num++;
  369. }
  370. if (
  371. parseInt(item.rowSpan) > 1 &&
  372. zindex == index &&
  373. this.hangIndex <= parseInt(item.rowSpan) + i - 1
  374. ) {
  375. item.rowSpan = parseInt(item.rowSpan) - 1;
  376. }
  377. });
  378. if (num == this.dataBody.rows[i].length) {
  379. return;
  380. }
  381. }
  382. }
  383. });
  384. this.dataBody.rows.splice(this.hangIndex, 1);
  385. },
  386. getInitData(val) {
  387. this.loading = true;
  388. this.$http({
  389. url: "/market/kpidepts/load",
  390. method: "post",
  391. headers: {
  392. "Content-Type": "application/json",
  393. },
  394. data: {
  395. kpiMonth: this.monthValue,
  396. receiveDeptCode: val,
  397. tempType: "0",
  398. subType: "a",
  399. },
  400. }).then((res) => {
  401. if (res.data.result == 0) {
  402. this.dataBody = res.data.body;
  403. } else {
  404. this.$message({
  405. message: "无绩效数据",
  406. type: "success",
  407. });
  408. this.dataBody.rows = [];
  409. }
  410. this.loading = false;
  411. });
  412. },
  413. },
  414. mounted() {},
  415. };
  416. </script>
  417. <style>
  418. #tabbox .el-input.is-disabled .el-input__inner {
  419. color: black;
  420. background-color: white;
  421. }
  422. .btn-wrapper-simple {
  423. height: auto !important;
  424. }
  425. </style>
  426. <style lang="scss" scoped>
  427. #tabbox {
  428. height: 75%;
  429. overflow-y: auto;
  430. }
  431. .dataBody-box {
  432. border-collapse: collapse;
  433. margin-top: 20px;
  434. .cell {
  435. position: relative;
  436. }
  437. }
  438. .fcous {
  439. border-color: red;
  440. }
  441. .center-style {
  442. display: flex;
  443. align-items: center;
  444. justify-content: center;
  445. height: 100%;
  446. }
  447. .auto-dom {
  448. width: 3px;
  449. opacity: 0;
  450. position: absolute;
  451. right: 0;
  452. top: 0;
  453. z-index: 1000;
  454. cursor: pointer;
  455. height: 100%;
  456. }
  457. </style>>
  458. <style scoped lang="scss">
  459. .btn-default {
  460. display: inline;
  461. margin-left: 10px;
  462. }
  463. .titbox {
  464. margin-bottom: 20px;
  465. div {
  466. float: right;
  467. i {
  468. font-size: 22px;
  469. margin-left: 20px;
  470. cursor: pointer;
  471. }
  472. }
  473. }
  474. .tabbox {
  475. margin-top: 15px;
  476. }
  477. .pageBox {
  478. text-align: right;
  479. margin-top: 10px;
  480. }
  481. </style>