sheet.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986
  1. <!--
  2. * @Author : yuanrunwei
  3. * @Date : 2021-12-04 14:23:58
  4. * @LastEditors: daiqisheng
  5. * @LastEditTime: 2022-03-07 17:40:14
  6. * @FilePath : \spfm-market-front\src\pages\main\performance\components\sheet.vue
  7. -->
  8. <template>
  9. <div class="sheet-container">
  10. <div class="flex-justify-align-end margin-bottom-20">
  11. <el-button
  12. type="primary"
  13. @click="handleVisible"
  14. v-if="['template'].includes(attribute)"
  15. >权限设置</el-button
  16. >
  17. <el-button type="primary" @click="handleDownload">导出</el-button>
  18. <el-button type="primary" @click="handleFullscreen()">全屏显示</el-button>
  19. <template v-if="['edit'].includes(type)">
  20. <el-upload
  21. v-if="!id"
  22. class="margin-right-10 margin-left-10"
  23. action
  24. :on-change="handleChange"
  25. :show-file-list="false"
  26. >
  27. <el-button type="primary">上传</el-button>
  28. </el-upload>
  29. <el-button
  30. v-if="!status || status === '2'"
  31. type="primary"
  32. @click="handleSave('2')"
  33. :disabled="handleForbid()"
  34. >暂存</el-button
  35. >
  36. <el-button
  37. v-if="status === '2' || status === '3'"
  38. type="primary"
  39. @click="handleResave"
  40. :disabled="handleForbid()"
  41. >保存</el-button
  42. >
  43. <el-button
  44. v-if="addFlag === '0'"
  45. type="primary"
  46. @click="handleSave('0')"
  47. :disabled="handleForbid()"
  48. ><span>{{ id ? "提交" : "新增" }}</span
  49. ><span>{{
  50. handleForbid() ? `(请先设置权限)` : ""
  51. }}</span></el-button
  52. >
  53. </template>
  54. </div>
  55. <div id="luckysheet" class="sheet-container-block"></div>
  56. <simple-dialog
  57. title="权限设置"
  58. :visible="visible"
  59. :modal="false"
  60. width="1400px"
  61. @confirm="handleAuth"
  62. @cancel="handleVisible"
  63. >
  64. <el-form ref="form" :model="form" label-width="80px">
  65. <el-radio-group
  66. v-model="form.permission_type"
  67. :disabled="type !== 'edit'"
  68. >
  69. <el-form-item>
  70. <el-radio :label="0"><span>无特殊权限</span></el-radio>
  71. <div>
  72. <span class="form-content">负责人</span>
  73. <el-select
  74. v-model="form.person"
  75. multiple
  76. placeholder="请选择负责人"
  77. :disabled="type !== 'edit'"
  78. >
  79. <el-option
  80. v-for="({ label, value }, index) in charge_list"
  81. :key="index"
  82. :label="label"
  83. :value="value"
  84. ></el-option>
  85. </el-select>
  86. </div>
  87. </el-form-item>
  88. <el-form-item>
  89. <el-radio :label="1"><span>特殊权限:</span></el-radio>
  90. <el-form-item
  91. label="负责人"
  92. prop="charge"
  93. v-for="(item, index) in form.charge"
  94. :key="index"
  95. :rules="{
  96. required: true,
  97. message: '负责人不能为空',
  98. trigger: 'blur',
  99. }"
  100. >
  101. <div class="flex">
  102. <el-select
  103. class="margin-bottom-20 margin-right-10"
  104. placeholder="请选择负责人"
  105. v-model="item.person"
  106. filterable
  107. :disabled="type !== 'edit'"
  108. >
  109. <el-option
  110. v-for="({ label, value }, index) in charge_list"
  111. :key="index"
  112. :label="label"
  113. :value="value"
  114. ></el-option>
  115. </el-select>
  116. <div class="form-select">
  117. <span class="form-content">可编辑行:从</span>
  118. <el-input
  119. v-model="item.row_start"
  120. @input="(params) => handleInput(index, 'row_start', params)"
  121. :disabled="type !== 'edit'"
  122. />
  123. <span class="form-content">到</span>
  124. <el-input
  125. v-model="item.row_end"
  126. @input="(params) => handleInput(index, 'row_end', params)"
  127. :disabled="type !== 'edit'"
  128. />
  129. </div>
  130. <div class="form-select">
  131. <span class="form-content">可编辑列:从</span>
  132. <el-input
  133. :disabled="type !== 'edit'"
  134. v-model="item.col_start"
  135. />
  136. <!-- @input="(params) => handleInput(index, 'col_start', params)" -->
  137. <span class="form-content">到</span>
  138. <el-input
  139. :disabled="type !== 'edit'"
  140. v-model="item.col_end"
  141. />
  142. </div>
  143. </div>
  144. </el-form-item>
  145. <div>
  146. <el-button
  147. @click.prevent="handleCharge('add')"
  148. :disabled="type !== 'edit'"
  149. >添加</el-button
  150. >
  151. <el-button
  152. v-if="form.charge.length - 1"
  153. @click.prevent="handleCharge('delete')"
  154. :disabled="type !== 'edit'"
  155. >删除</el-button
  156. >
  157. </div>
  158. </el-form-item>
  159. </el-radio-group>
  160. </el-form>
  161. <template v-if="id && status !== '2' && status !== '3'" v-slot:footer
  162. ><div></div
  163. ></template>
  164. </simple-dialog>
  165. <simpleDialog
  166. title="提交"
  167. :visible="manager_approve"
  168. :modal="false"
  169. @cancel="handleApprove(0)"
  170. >
  171. <el-form :model="approveForm" label-width="120px">
  172. <el-form-item
  173. label="审批意见:"
  174. :rules="{
  175. required: true,
  176. message: '请选择审批意见',
  177. trigger: 'change',
  178. }"
  179. >
  180. <el-select v-model="approveForm.type">
  181. <el-option
  182. v-for="item in approveForm.list"
  183. :key="item.value"
  184. :label="item.label"
  185. :value="item.value"
  186. >
  187. </el-option>
  188. </el-select>
  189. </el-form-item>
  190. <el-form-item
  191. v-if="approveForm.type === '3'"
  192. label="其它审批意见:"
  193. :rules="{
  194. required: true,
  195. message: '请输入审批意见',
  196. trigger: 'blur',
  197. }"
  198. ><el-input v-model="approveForm.comments"
  199. /></el-form-item>
  200. </el-form>
  201. <template v-slot:footer>
  202. <div>
  203. <el-button @click.prevent="handleApprove('1')">结束</el-button>
  204. <el-button @click.prevent="handleApprove('4')" type="primary"
  205. >转副总审批</el-button
  206. >
  207. <el-button @click.prevent="handleApprove('3')" type="primary"
  208. >转总经理审批</el-button
  209. >
  210. </div>
  211. </template>
  212. </simpleDialog>
  213. </div>
  214. </template>
  215. <script>
  216. import luckyexcel from "luckyexcel";
  217. import { exportExcel } from "../common/export";
  218. import simpleDialog from "./dialog.vue";
  219. export default {
  220. components: {
  221. simpleDialog,
  222. },
  223. props: {
  224. type: {
  225. type: String,
  226. default: "view", // view 查看 edit 编辑
  227. },
  228. attribute: {
  229. type: String,
  230. default: "template", // template 模板 order 工单 file 文件
  231. },
  232. id: {
  233. default: null,
  234. },
  235. receiver: {
  236. type: String,
  237. default: "",
  238. },
  239. status: { type: String, default: "" },
  240. },
  241. data() {
  242. return {
  243. form: {
  244. charge: [
  245. {
  246. person: [],
  247. col_start: "",
  248. col_end: "",
  249. row_start: "",
  250. row_end: "",
  251. },
  252. ],
  253. array: [],
  254. type: null,
  255. permission_type: null,
  256. col_start: "",
  257. col_end: "",
  258. row_start: "",
  259. row_end: "",
  260. },
  261. approveForm: {
  262. type: "",
  263. comments: "",
  264. list: [
  265. {
  266. label: "同意",
  267. value: "同意",
  268. },
  269. {
  270. label: "不同意",
  271. value: "不同意",
  272. },
  273. {
  274. label: "其他",
  275. value: "3",
  276. },
  277. ],
  278. },
  279. // 可提交标志
  280. addFlag: "0",
  281. rowList: [],
  282. isDisable: true,
  283. issued_id: null,
  284. template_id: null,
  285. visible: false,
  286. manager_approve: false,
  287. row_list: [],
  288. column_list: [],
  289. charge_list: [],
  290. type_options: [
  291. {
  292. value: 1,
  293. label: "按行",
  294. },
  295. // {
  296. // value: 2,
  297. // label: "按列",
  298. // },
  299. ],
  300. };
  301. },
  302. methods: {
  303. handleInit() {
  304. if (this.id) {
  305. this.handleQuery();
  306. } else {
  307. this.handleCreate();
  308. }
  309. },
  310. // // 权限选择
  311. // handleRadio(e){
  312. // console.log(e,'e');
  313. // },
  314. handleAllow({ row, column }) {
  315. let public_permisson =
  316. (!this.form.permission_type ||
  317. this.status === "2" ||
  318. this.status === "3") &&
  319. this.type === "edit";
  320. let editable =
  321. this.row_list.includes(row) && this.column_list.includes(column);
  322. // let totalBoolean = (public_permisson || editable) && this.id;
  323. let totalBoolean = public_permisson || editable;
  324. return totalBoolean;
  325. },
  326. async handleQuery() {
  327. let url = "";
  328. let params = {};
  329. switch (this.attribute) {
  330. case "template":
  331. url = "/market/CMKFileTemplate/QueryCMKFileTemplateById";
  332. params = {
  333. templateId: this.id,
  334. };
  335. break;
  336. case "order":
  337. url = "/market/CMKIssued/CMKQueryIssuedById";
  338. params = {
  339. id: this.id,
  340. };
  341. break;
  342. case "file":
  343. url = "/market/CMKIssued/CMKIssuedProcessByUser";
  344. params = {
  345. id: this.id,
  346. receiverId: this.receiver,
  347. };
  348. break;
  349. }
  350. const {
  351. data: {
  352. templateContent,
  353. templateName,
  354. issuedId,
  355. templateId,
  356. list,
  357. addFlag,
  358. },
  359. } = await this.$http({
  360. url,
  361. method: "post",
  362. headers: {
  363. "Content-Type": "application/json",
  364. },
  365. data: params,
  366. });
  367. this.template_id = templateId;
  368. this.issued_id = issuedId;
  369. this.addFlag = addFlag;
  370. console.log(JSON.parse(templateContent), "123123");
  371. if (list && list.length) {
  372. const { type } = list[0];
  373. if (type === "1") {
  374. // 公共权限
  375. // const { allowEditingColumns, rowNum } = list[0];
  376. this.form = {
  377. permission_type: Number(type) - 1,
  378. person: list.map((el) => {
  379. return `${el.principalMent}-${el.principalId},${el.principalName}`;
  380. }),
  381. charge: [
  382. {
  383. person: "",
  384. col_start: "",
  385. col_end: "",
  386. row_start: "",
  387. row_end: "",
  388. },
  389. ],
  390. };
  391. } else {
  392. // 特殊权限
  393. this.form = {
  394. permission_type: Number(type) - 1,
  395. col_start: "",
  396. col_end: "",
  397. row_start: "",
  398. row_end: "",
  399. charge: list.map((el) => ({
  400. person: `${el.principalMent}-${el.principalId},${el.principalName}`,
  401. col_start: el.allowEditingColumns.split(",")[0],
  402. col_end:
  403. el.allowEditingColumns.split(",")[
  404. el.allowEditingColumns.split(",").length - 1
  405. ],
  406. row_start: el.rowNum.split(",")[0],
  407. row_end: el.rowNum.split(",")[el.rowNum.split(",").length - 1],
  408. })),
  409. };
  410. }
  411. this.row_list =
  412. this.type === "edit" && list[0].rowNum
  413. ? list[0].rowNum
  414. .split(",")
  415. .map((element) => JSON.parse(element) - 1)
  416. : [];
  417. if (this.type === "edit" && list[0].allowEditingColumns) {
  418. // this.column_list = list[0].allowEditingColumns
  419. // .split(",")
  420. // .map((element) => JSON.parse(element) - 1);
  421. this.column_list =
  422. list[0].allowEditingColumnsFlag === "1"
  423. ? list[0].allowEditingColumnsShuzi
  424. .split(",")
  425. .map((element) => JSON.parse(element) - 1)
  426. : list[0].allowEditingColumns
  427. .split(",")
  428. .map((element) => JSON.parse(element) - 1);
  429. } else {
  430. this.column_list = [];
  431. }
  432. // this.formateNumber(list[0].allowEditingColumns);
  433. }
  434. this.handleCreate({
  435. json: templateContent ? JSON.parse(templateContent) : {},
  436. name: templateName,
  437. type: "json",
  438. });
  439. },
  440. handleForbid() {
  441. // const object = {};
  442. const { permission_type } = this.form;
  443. if (permission_type === 0) {
  444. // 公共权限 暂时不用可编辑行和列
  445. const { person } = this.form;
  446. if (person.length) {
  447. return false;
  448. }
  449. return true;
  450. } else if (permission_type === 1) {
  451. // 特殊权限
  452. let flag = 1;
  453. const { charge } = this.form;
  454. charge.forEach((el) => {
  455. if (
  456. Object.values(el).filter((v) => {
  457. return v !== "";
  458. }).length === 5
  459. ) {
  460. flag = flag * 1;
  461. } else {
  462. flag = flag * 0;
  463. }
  464. });
  465. return !flag;
  466. } else {
  467. return true;
  468. }
  469. },
  470. async handleCreate({ file, json, type, name } = {}) {
  471. let that = this;
  472. const options = {
  473. container: "luckysheet",
  474. lang: "zh",
  475. showsheetbar: false,
  476. hook: {
  477. cellEditBefore: function ([
  478. { row_focus: row, column_focus: column },
  479. ]) {
  480. if (!that.handleAllow({ row, column })) {
  481. that.$message.error("您没有编辑权限");
  482. }
  483. },
  484. // cellUpdated: function (row, column) {
  485. // that.rowList.push(row);
  486. // },
  487. cellUpdateBefore: function (row, column) {
  488. if (!that.handleAllow({ row, column })) {
  489. return false;
  490. }
  491. },
  492. cellRenderAfter: function (cell, position) {
  493. const { r: row, c: column } = position;
  494. console.log();
  495. if (cell) {
  496. if (!that.handleAllow({ row, column })) {
  497. cell.bg = "#d5d5d5";
  498. } else {
  499. cell.bg = "#ffffff";
  500. }
  501. }
  502. },
  503. updated: function ({ range }) {
  504. const middle = range.map((el) => {
  505. return that.paramsArr(el.row[0], el.row[1]);
  506. });
  507. let changedList = middle.join(",").split(",");
  508. that.rowList.push(...changedList);
  509. console.log(that.rowList, "that.rowList");
  510. },
  511. },
  512. };
  513. switch (type) {
  514. case "file":
  515. if (file) {
  516. await new Promise((resolve) => {
  517. luckyexcel.transformExcelToLucky(file, (export_json) => {
  518. options.data = [
  519. ...export_json.sheets.map((element) => ({
  520. ...element,
  521. zoomRatio: 0.75,
  522. })),
  523. ];
  524. options.title = export_json.info.name;
  525. resolve();
  526. });
  527. });
  528. }
  529. break;
  530. case "json":
  531. if (json) {
  532. options.data = [
  533. {
  534. ...json,
  535. zoomRatio: 0.75,
  536. },
  537. ];
  538. options.title = name;
  539. }
  540. break;
  541. }
  542. window.luckysheet.create(options);
  543. let clock = setInterval(() => {
  544. if (window.luckysheet) {
  545. window.luckysheet.refresh();
  546. clearInterval(clock);
  547. }
  548. }, 1000);
  549. },
  550. async handleChange(response) {
  551. this.handleCreate({ file: response.raw, type: "file" });
  552. },
  553. handleDownload() {
  554. exportExcel(
  555. window.luckysheet.getAllSheets(),
  556. window.luckysheet.getWorkbookName()
  557. );
  558. },
  559. async handleAddAuth({ id }) {
  560. // const object = {};
  561. const { permission_type } = this.form;
  562. console.log(id, permission_type);
  563. let reqdata = {
  564. templateId: id,
  565. type: permission_type ? 2 : 1,
  566. };
  567. if (!permission_type) {
  568. // 公共权限
  569. const { person } = this.form;
  570. const principalId = [];
  571. const principalName = [];
  572. const principalMent = [];
  573. person.forEach((el) => {
  574. principalMent.push(el.split(",")[0].split("-")[0]);
  575. principalId.push(el.split(",")[0].split("-")[1]);
  576. principalName.push(el.split(",")[1]);
  577. });
  578. reqdata.principalId = principalId.join(",");
  579. reqdata.principalName = principalName.join(",");
  580. reqdata.principalMent = principalName.join(",");
  581. } else {
  582. const { charge } = this.form;
  583. // 特殊权限
  584. reqdata.specialAuth = charge.map((el) =>
  585. JSON.stringify({
  586. allowEditingColumns: `${el.col_start},${el.col_end}`,
  587. rowNum: `${el.row_start},${el.row_end}`,
  588. principalMent: el.person.split(",")[0].split("-")[0],
  589. principalId: el.person.split(",")[0].split("-")[1],
  590. principalName: el.person.split(",")[1],
  591. })
  592. );
  593. }
  594. const {
  595. data: { result, desc },
  596. } = await this.$http({
  597. url: this.id
  598. ? "/market/CMKFileTemplateAuthority/CMKFileTemplateAuthorityUpdate"
  599. : "/market/CMKFileTemplateAuthority/CMKFileTemplateAuthorityAdd",
  600. method: "post",
  601. headers: {
  602. "Content-Type": "application/json",
  603. },
  604. data: reqdata,
  605. });
  606. if (result) {
  607. this.$message.error(desc);
  608. } else {
  609. this.$message.success(desc);
  610. }
  611. return result;
  612. },
  613. async handleSave(type) {
  614. let edit_url = "";
  615. switch (this.attribute) {
  616. case "template":
  617. edit_url = "";
  618. break;
  619. case "order":
  620. edit_url = "";
  621. break;
  622. case "file":
  623. edit_url = "/market/CMKIssued/CMKIssuedSubmit";
  624. break;
  625. }
  626. const sheet_name = window.luckysheet.getSheet().name;
  627. const data = window.luckysheet.getSheet(sheet_name);
  628. const workbook_name = window.luckysheet.getWorkbookName();
  629. if (!this.id) {
  630. // 新增时添加权限
  631. const {
  632. data: { body },
  633. } = await this.$http({
  634. url: "/market/CMKFileTemplate/CMKFileTemplateAdd", // 新增
  635. method: "post",
  636. headers: {
  637. "Content-Type": "application/json",
  638. },
  639. data: {
  640. id: this.template_id,
  641. templateContent: JSON.stringify(data),
  642. templateName: workbook_name,
  643. issuedId: this.issued_id,
  644. status: type,
  645. },
  646. });
  647. await this.handleAddAuth({ id: body });
  648. this.$emit("save");
  649. } else {
  650. // 职位
  651. let duty = JSON.parse(sessionStorage.userInfo).duty;
  652. if (duty === "7") {
  653. this.manager_approve = true;
  654. } else {
  655. if (type === "2") {
  656. // 暂存
  657. await this.$http({
  658. url: "/market/CMKFileTemplate/UptateCMKFileTemplateById", // 新增
  659. method: "post",
  660. headers: {
  661. "Content-Type": "application/json",
  662. },
  663. data: {
  664. templateId: this.id,
  665. templateContent: JSON.stringify(data),
  666. templateName: workbook_name,
  667. status: type,
  668. },
  669. });
  670. this.$emit("save");
  671. return;
  672. }
  673. // 员工提交
  674. this.rowList.shift();
  675. let reqdata = {
  676. rowIndex: [...new Set(this.rowList)]
  677. .sort(function (a, b) {
  678. return a - b;
  679. })
  680. .join(","),
  681. rowContent: [...new Set(this.rowList)]
  682. .sort(function (a, b) {
  683. return a - b;
  684. })
  685. .map((el) => {
  686. return data.data[el];
  687. }),
  688. };
  689. await this.$http({
  690. url: edit_url, //提交
  691. method: "post",
  692. headers: {
  693. "Content-Type": "application/json",
  694. },
  695. data: {
  696. id: this.template_id,
  697. templateContent: JSON.stringify(data),
  698. templateName: workbook_name,
  699. issuedId: this.issued_id,
  700. rowJson: JSON.stringify(reqdata),
  701. },
  702. });
  703. this.$emit("save");
  704. }
  705. }
  706. },
  707. // 判断数组是否有值
  708. confirmArrayData(data) {
  709. if (data instanceof Array) {
  710. let flag = 0;
  711. if (data.length) {
  712. data.forEach((el) => {
  713. if (el instanceof Object) {
  714. flag = flag + 1;
  715. }
  716. });
  717. if (flag) {
  718. return true;
  719. } else {
  720. return false;
  721. }
  722. } else {
  723. return false;
  724. }
  725. } else {
  726. return false;
  727. }
  728. },
  729. async handleAuth() {
  730. this.$refs["form"].validate((valid) => {
  731. if (valid) {
  732. if (this.handleForbid()) {
  733. this.$message.error("请完善可编辑信息");
  734. return false;
  735. }
  736. if (this.id) {
  737. this.handleAddAuth({ id: this.id });
  738. }
  739. this.handleVisible();
  740. }
  741. });
  742. },
  743. // 通用方法用于转化全局
  744. paramsArr(start, end) {
  745. const arr = [];
  746. console.log(start, end);
  747. for (let i = Number(start); i <= Number(end); i++) {
  748. arr.push(i);
  749. }
  750. return arr.join(",");
  751. },
  752. filterName(id, arr) {
  753. return arr.filter((el) => el.secLeaderLogin === id)[0].secLeaderName;
  754. },
  755. handleCharge(type) {
  756. switch (type) {
  757. case "add":
  758. this.form.charge.push({
  759. person: "",
  760. });
  761. this.handleForbid();
  762. break;
  763. case "delete":
  764. this.form.charge.pop();
  765. this.handleForbid();
  766. break;
  767. }
  768. },
  769. handleVisible() {
  770. this.visible = !this.visible;
  771. },
  772. handleInput(index, name, value) {
  773. let reg = /^[0-9]*$/;
  774. if (!reg.test(value)) {
  775. this.form.charge[index][name] = this.form.charge[index][name].substr(
  776. 0,
  777. this.form.charge[index][name].length - 1
  778. );
  779. this.$message.error("该处只能填写数字");
  780. }
  781. },
  782. async handleApprove(type) {
  783. if (type) {
  784. if (this.approveForm.type) {
  785. if (this.approveForm.type === "3" && !this.approveForm.comments) {
  786. this.$message.error("请输入其他审批意见");
  787. return;
  788. }
  789. } else {
  790. this.$message.error("请选择审批意见");
  791. return;
  792. }
  793. const sheet_name = window.luckysheet.getSheet().name;
  794. const data = window.luckysheet.getSheet(sheet_name);
  795. const workbook_name = window.luckysheet.getWorkbookName();
  796. // 经理提交
  797. this.rowList.shift();
  798. let reqdata = {
  799. rowIndex: [...new Set(this.rowList)]
  800. .sort(function (a, b) {
  801. return a - b;
  802. })
  803. .join(","),
  804. rowContent: [...new Set(this.rowList)]
  805. .sort(function (a, b) {
  806. return a - b;
  807. })
  808. .map((el) => {
  809. return data.data[el];
  810. }),
  811. };
  812. await this.$http({
  813. url: "/market/CMKIssued/CMKIssuedSubmit", // 提交
  814. method: "post",
  815. headers: {
  816. "Content-Type": "application/json",
  817. },
  818. data: {
  819. id: this.template_id,
  820. templateContent: JSON.stringify(data),
  821. templateName: workbook_name,
  822. issuedId: this.issued_id,
  823. rowJson: JSON.stringify(reqdata),
  824. },
  825. });
  826. let params = {
  827. id: this.issued_id,
  828. reviewOpinion:
  829. this.approveForm.type === "3"
  830. ? this.approveForm.comments
  831. : this.approveForm.type,
  832. };
  833. switch (type) {
  834. case "1":
  835. params = {
  836. ...params,
  837. operateName: "结束",
  838. status: 3,
  839. };
  840. break;
  841. case "4":
  842. params = {
  843. ...params,
  844. operateName: "转副总审批",
  845. reviewType: 2,
  846. };
  847. break;
  848. case "3":
  849. params = {
  850. ...params,
  851. operateName: "转总经理审批",
  852. reviewType: 3,
  853. };
  854. break;
  855. }
  856. await this.$http({
  857. url: "/market/CMKIssued/CMKIssuedCheck", // 审批
  858. method: "post",
  859. headers: {
  860. "Content-Type": "application/json",
  861. },
  862. data: params,
  863. });
  864. this.$message({
  865. type: "success",
  866. message: "审批成功",
  867. });
  868. this.manager_approve = false;
  869. this.$emit("save");
  870. } else {
  871. this.manager_approve = false;
  872. }
  873. },
  874. handleFullscreen() {
  875. const element = document.body;
  876. const is_fullscreen =
  877. document.fullScreen ||
  878. document.mozFullScreen ||
  879. document.webkitIsFullScreen;
  880. if (!is_fullscreen) {
  881. //进入全屏,多重短路表达式
  882. (element.requestFullscreen && element.requestFullscreen()) ||
  883. (element.mozRequestFullScreen && element.mozRequestFullScreen()) ||
  884. (element.webkitRequestFullscreen &&
  885. element.webkitRequestFullscreen()) ||
  886. (element.msRequestFullscreen && element.msRequestFullscreen());
  887. } else {
  888. //退出全屏,三目运算符
  889. document.exitFullscreen
  890. ? document.exitFullscreen()
  891. : document.mozCancelFullScreen
  892. ? document.mozCancelFullScreen()
  893. : document.webkitExitFullscreen
  894. ? document.webkitExitFullscreen()
  895. : "";
  896. }
  897. },
  898. handleResave() {
  899. const sheet_name = window.luckysheet.getSheet().name;
  900. const data = window.luckysheet.getSheet(sheet_name);
  901. const workbook_name = window.luckysheet.getWorkbookName();
  902. this.$http({
  903. url: "/market/CMKFileTemplate/UptateCMKFileTemplateById",
  904. method: "post",
  905. headers: {
  906. "Content-Type": "application/json",
  907. },
  908. data: {
  909. templateId: this.id,
  910. templateContent: JSON.stringify(data),
  911. templateName: workbook_name,
  912. status: "0",
  913. },
  914. }).then(() => {
  915. this.$emit("save");
  916. });
  917. },
  918. handleChargeList() {
  919. this.$http({
  920. url: "/market/techcentergj/queryLeaderList",
  921. method: "post",
  922. headers: {
  923. "Content-Type": "application/json",
  924. },
  925. data: {},
  926. }).then((response) => {
  927. this.charge_list = response.data.map((element) => ({
  928. label: `${element.ou} ${element.secLeaderName}`,
  929. value: `${element.ou}-${element.secLeaderLogin},${element.secLeaderName}`,
  930. }));
  931. });
  932. },
  933. },
  934. mounted() {
  935. console.log(this.destroy, "destroy");
  936. this.handleInit();
  937. this.handleChargeList();
  938. },
  939. destroyed() {
  940. window.luckysheet.destroy();
  941. },
  942. };
  943. </script>
  944. <style lang="scss" scope>
  945. .sheet-container {
  946. position: fixed;
  947. width: calc(100% - 40px);
  948. height: 100%;
  949. &-block {
  950. overflow: hidden;
  951. position: absolute;
  952. width: 100%;
  953. height: 75%;
  954. }
  955. }
  956. .form {
  957. &-input {
  958. margin-top: 5px;
  959. .el-input {
  960. width: 150px;
  961. .el-input__inner {
  962. height: 30px !important;
  963. line-height: 30px !important;
  964. }
  965. }
  966. }
  967. &-content {
  968. margin: 0px 10px;
  969. }
  970. &-select {
  971. .el-input {
  972. width: 100px;
  973. .el-input__inner {
  974. height: 30px !important;
  975. line-height: 30px !important;
  976. }
  977. }
  978. }
  979. }
  980. </style>