sheet1.vue 29 KB

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