company.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518
  1. * @Author : yuanrunwei
  2. * @Date : 2021-12-04 14:23:58
  3. * @LastEditors: daiqisheng
  4. * @LastEditTime: 2022-04-25 19:11:41
  5. * @FilePath : \spfm-market-front\src\pages\main\performance\components\sheet.vue
  6. -->
  7. <template>
  8. <div class="sheet-container">
  9. <div style="margin: 20px 0 40px 0; display: flex">
  10. 运营商:
  11. <el-select v-model="bednumber" @change="getCheck()">
  12. <el-option
  13. v-for="(item, index) in options"
  14. :key="index"
  15. :label="item.value"
  16. :value="item.value"
  17. ></el-option>
  18. </el-select>
  19. <el-button type="primary" @click="handleResave"
  20. >保存</el-button
  21. >
  22. <el-upload
  23. class="upload-demo"
  24. multiple
  25. ref="upload"
  26. action="string"
  27. :http-request="clickok"
  28. :before-upload="deforeUp"
  29. :on-change="handleChange"
  30. >
  31. <div>
  32. <i class="el-icon-upload"></i>
  33. <div class="el-upload__text">点击上传</div>
  34. </div>
  35. <div>
  36. <el-button>123</el-button>
  37. </div>
  38. </el-upload>
  39. <el-button type="primary" @click="handleDownload">导出</el-button>
  40. <el-button type="primary" @click="handleFullscreen()">全屏显示</el-button>
  41. </div>
  42. <div id="luckysheet" style="width: 75%; height: 70%"></div>
  43. </div>
  44. </template>
  45. <script>
  46. import luckyexcel from "luckyexcel";
  47. import { exportExcel } from "./components//export.js";
  48. // import simpleDialog from "./dialog.vue";z
  49. export default {
  50. components: {
  51. // simpleDialog,
  52. },
  53. props: {
  54. type: {
  55. type: String,
  56. default: "view", // view 查看 edit 编辑
  57. },
  58. attribute: {
  59. type: String,
  60. default: "template", // template 模板 order 工单 file 文件
  61. },
  62. id: {
  63. default: null,
  64. },
  65. // 接收人
  66. receiver: {
  67. type: String,
  68. default: "",
  69. },
  70. // 模板状态按钮判断
  71. status: { type: String, default: "" },
  72. },
  73. data() {
  74. return {
  75. bednumber: "",
  76. checkStatus: false,
  77. unicomList: [], //联通excelList
  78. telecomList: [], //电信excelList
  79. options: [
  80. {
  81. value: "电信",
  82. },
  83. {
  84. value: "联通",
  85. },
  86. ],
  87. dialogTableVisible: true,
  88. celldata: [
  89. { r: 0, c: 0, v: { v: "运营商", bl: 1, ht: 0, vt: 0 } },
  90. {
  91. r: 0,
  92. c: 1,
  93. tb: 2,
  94. v: {
  95. tb: 2,
  96. fs: 11,
  97. ht: 0,
  98. vt: 0,
  99. v: "套餐档位(从低到高进行填写)低档:58元以下套餐中档:58元(含)-128元套餐(不含)高档:128元及以上套餐",
  100. ct: { fa: "General", t: "n" },
  101. m: "2",
  102. },
  103. },
  104. {
  105. r: 0,
  106. c: 2,
  107. v: {
  108. fc: "rgb(51, 51, 51)",
  109. ht: 0,
  110. vt: 0,
  111. v: "套餐名称",
  112. ct: { fa: "General", t: "n" },
  113. m: "3",
  114. },
  115. },
  116. {
  117. r: 0,
  118. c: 3,
  119. v: {
  120. bl: 0,
  121. it: 0,
  122. ff: 0,
  123. fs: 11,
  124. fc: "rgb(51, 51, 51)",
  125. ht: 0,
  126. vt: 0,
  127. v: "是否为主推套餐",
  128. ct: { fa: "General", t: "n" },
  129. m: "0",
  130. },
  131. },
  132. {
  133. r: 0,
  134. c: 4,
  135. v: {
  136. v: "月费(元)",
  137. bl: 0,
  138. it: 0,
  139. ff: 0,
  140. fs: 11,
  141. fc: "rgb(51, 51, 51)",
  142. ht: 0,
  143. vt: 0,
  144. },
  145. },
  146. {
  147. r: 0,
  148. c: 5,
  149. v: {
  150. v: "优惠价",
  151. bl: 0,
  152. it: 0,
  153. ff: 0,
  154. fs: 11,
  155. fc: "rgb(51, 51, 51)",
  156. ht: 0,
  157. vt: 0,
  158. },
  159. },
  160. {
  161. r: 0,
  162. c: 6,
  163. v: {
  164. v: "预存款(元)",
  165. bl: 0,
  166. it: 0,
  167. ff: 0,
  168. fs: 11,
  169. fc: "rgb(51, 51, 51)",
  170. ht: 0,
  171. vt: 0,
  172. },
  173. },
  174. {
  175. r: 0,
  176. c: 7,
  177. v: {
  178. v: "套餐内容",
  179. bl: 0,
  180. it: 0,
  181. ff: 0,
  182. fs: 11,
  183. fc: "rgb(51, 51, 51)",
  184. ht: 0,
  185. vt: 0,
  186. },
  187. },
  188. {
  189. r: 0,
  190. c: 8,
  191. v: {
  192. v: "酬金",
  193. bl: 0,
  194. it: 0,
  195. ff: 0,
  196. fs: 11,
  197. fc: "rgb(51, 51, 51)",
  198. ht: 0,
  199. vt: 0,
  200. },
  201. },
  202. {
  203. r: 0,
  204. c: 9,
  205. v: {
  206. v: "在售区域",
  207. bl: 0,
  208. it: 0,
  209. ff: 0,
  210. fs: 11,
  211. fc: "rgb(51, 51, 51)",
  212. ht: 0,
  213. vt: 0,
  214. },
  215. },
  216. {
  217. r: 0,
  218. c: 10,
  219. v: {
  220. v: "在售渠道",
  221. bl: 0,
  222. it: 0,
  223. ff: 0,
  224. fs: 11,
  225. fc: "rgb(51, 51, 51)",
  226. ht: 0,
  227. vt: 0,
  228. },
  229. },
  230. {
  231. r: 0,
  232. c: 11,
  233. v: {
  234. v: "月销量",
  235. bl: 0,
  236. it: 0,
  237. ff: 0,
  238. fs: 11,
  239. fc: "rgb(51, 51, 51)",
  240. ht: 0,
  241. vt: 0,
  242. },
  243. },
  244. {
  245. r: 0,
  246. c: 12,
  247. v: {
  248. v: "是否包含宽带",
  249. bl: 0,
  250. it: 0,
  251. ff: 0,
  252. fs: 11,
  253. fc: "rgb(51, 51, 51)",
  254. ht: 0,
  255. vt: 0,
  256. },
  257. },
  258. {
  259. r: 0,
  260. c: 13,
  261. v: {
  262. v: "宽带具体内容",
  263. bl: 0,
  264. it: 0,
  265. ff: 0,
  266. fs: 11,
  267. fc: "rgb(51, 51, 51)",
  268. ht: 0,
  269. vt: 0,
  270. },
  271. },
  272. {
  273. r: 0,
  274. c: 14,
  275. v: {
  276. v: "是否包括电视",
  277. bl: 0,
  278. it: 0,
  279. ff: 0,
  280. fs: 11,
  281. fc: "rgb(51, 51, 51)",
  282. ht: 0,
  283. vt: 0,
  284. },
  285. },
  286. {
  287. r: 0,
  288. c: 15,
  289. v: {
  290. v: "是否包括副卡",
  291. bl: 0,
  292. it: 0,
  293. ff: 0,
  294. fs: 11,
  295. fc: "rgb(51, 51, 51)",
  296. ht: 0,
  297. vt: 0,
  298. },
  299. },
  300. {
  301. r: 0,
  302. c: 16,
  303. v: {
  304. v: "是否包括亲情网",
  305. bl: 0,
  306. it: 0,
  307. ff: 0,
  308. fs: 11,
  309. fc: "rgb(51, 51, 51)",
  310. ht: 0,
  311. vt: 0,
  312. },
  313. },
  314. {
  315. r: 0,
  316. c: 17,
  317. v: {
  318. v: "是否包括v网产品",
  319. bl: 0,
  320. it: 0,
  321. ff: 0,
  322. fs: 11,
  323. fc: "rgb(51, 51, 51)",
  324. ht: 0,
  325. vt: 0,
  326. },
  327. },
  328. {
  329. r: 0,
  330. c: 18,
  331. v: {
  332. v: "其他补充信息",
  333. bl: 0,
  334. it: 0,
  335. ff: 0,
  336. fs: 11,
  337. fc: "rgb(51, 51, 51)",
  338. ht: 0,
  339. vt: 0,
  340. },
  341. },
  342. {
  343. r: 0,
  344. c: 19,
  345. v: {
  346. v: "上报人",
  347. bl: 0,
  348. it: 0,
  349. ff: 0,
  350. fs: 11,
  351. fc: "rgb(51, 51, 51)",
  352. ht: 0,
  353. vt: 0,
  354. },
  355. },
  356. {
  357. r: 0,
  358. c: 20,
  359. v: {
  360. v: "联系电话",
  361. bl: 0,
  362. it: 0,
  363. ff: 0,
  364. fs: 11,
  365. fc: "rgb(51, 51, 51)",
  366. ht: 0,
  367. vt: 0,
  368. },
  369. },
  370. ],
  371. form: {
  372. charge: [
  373. {
  374. person: [],
  375. col_start: "",
  376. col_end: "",
  377. row_start: "",
  378. row_end: "",
  379. },
  380. ],
  381. array: [],
  382. type: null,
  383. permission_type: null,
  384. col_start: "",
  385. col_end: "",
  386. row_start: "",
  387. row_end: "",
  388. },
  389. approveForm: {
  390. type: "",
  391. comments: "",
  392. list: [
  393. {
  394. label: "同意",
  395. value: "同意",
  396. },
  397. {
  398. label: "不同意",
  399. value: "不同意",
  400. },
  401. {
  402. label: "其他",
  403. value: "3",
  404. },
  405. ],
  406. },
  407. superviserules: {
  408. distribute: [
  409. { required: true, message: "请选择派发周期", trigger: "change" },
  410. ],
  411. write: [
  412. { required: true, message: "请选择填报周期", trigger: "change" },
  413. ],
  414. endTime: [
  415. { required: true, message: "请选择截止时间", trigger: "change" },
  416. ],
  417. },
  418. superviseForm: {
  419. distribute: "", // 派单周期
  420. write: "", // 填写周期
  421. endTime: "", // 截止时间
  422. },
  423. originSuperviseForm: {},
  424. pickOptions: {
  425. disabledDate(time) {
  426. return time.getTime() < new Date().getTime() - 8.64e7;
  427. },
  428. },
  429. pickWrite: {
  430. disabledDate(time) {
  431. return time.getTime() < new Date().getTime() - 8.64e7;
  432. },
  433. },
  434. // 可提交标志
  435. addFlag: "0",
  436. // 督办标志
  437. superviseFlag: null,
  438. rowList: [],
  439. isDisable: true,
  440. issued_id: null,
  441. template_id: null,
  442. visible: false,
  443. templateType: "",
  444. // 督办
  445. supervise: false,
  446. manager_approve: false,
  447. row_list: [],
  448. column_list: [],
  449. charge_list: [],
  450. a: [],
  451. b: [],
  452. type_options: [
  453. {
  454. value: 1,
  455. label: "按行",
  456. },
  457. // {
  458. // value: 2,
  459. // label: "按列",
  460. // },
  461. ],
  462. };
  463. },
  464. // watch: {
  465. // bednumber(newVal,oldVal){
  466. // console.log(newVal,oldVal);
  467. // },
  468. // deep:true,
  469. // immediate:true
  470. //
  471. // },
  472. // created(){
  473. // console.log('123123123123');
  474. // },
  475. methods: {
  476. async getCheck() {
  477. if (this.bednumber === "联通") {
  478. Promise.all([await this.getUnicom(), await this.getUnicomList()]).then(
  479. (res) => {
  480. this.handleCreate(this.a);
  481. }
  482. );
  483. } else {
  484. Promise.all([await this.getMove(), await this.getMoveList()]).then(
  485. (res) => {
  486. this.handleCreate(this.b);
  487. }
  488. );
  489. }
  490. },
  491. async getUnicom() {
  492. await this.$http({
  493. url: "/market/expensesUnicom/loadProv",
  494. method: "post",
  495. headers: {
  496. "Content-Type": "application/json",
  497. },
  498. }).then((res) => {
  499. // this.handleCreate(res.data.body)
  500. res.data.body[0].subScript = 0;
  501. this.a = res.data.body;
  502. });
  503. },
  504. async getUnicomList() {
  505. await this.$http({
  506. url: "/market/questionnaireUnicom/loadProv",
  507. method: "post",
  508. headers: {
  509. "Content-Type": "application/json",
  510. },
  511. }).then((res) => {
  512. res.data.body[0].subScript = 1;
  513. this.a.push(res.data.body[0]);
  514. });
  515. },
  516. async getMove() {
  517. await this.$http({
  518. url: "/market/expensesTelecom/loadProv",
  519. method: "post",
  520. headers: {
  521. "Content-Type": "application/json",
  522. },
  523. }).then((res) => {
  524. res.data.body[0].subScript = 2;
  525. this.b = res.data.body;
  526. });
  527. },
  528. async getMoveList() {
  529. await this.$http({
  530. url: "/market/questionnaireTelecom/loadProv",
  531. method: "post",
  532. headers: {
  533. "Content-Type": "application/json",
  534. },
  535. }).then((res) => {
  536. res.data.body[0].subScript = 3;
  537. this.b.push(res.data.body[0]);
  538. });
  539. },
  540. //获取用户是否为外呼调研员
  541. async getJurisdiction() {
  542. await this.$http({
  543. url: "/market/questionnaireUnicom/queryRole",
  544. method: "post",
  545. headers: {
  546. "Content-Type": "application/json",
  547. },
  548. }).then((res) => {
  549. if(res.data.body === '0'){ //是外呼管理员
  550. this.clickOut = true //显示导出
  551. this.clickSave = false //不显示保存
  552. }else{
  553. this.clickOut = false //显示导出
  554. this.clickSave = true //不显示保存
  555. }
  556. console.log(res.body);
  557. });
  558. },
  559. // handleChange(file, fileList) {
  560. // console.log(file);
  561. // this.fileList = fileList.slice(-3);
  562. // },
  563. clickok() {},
  564. deforeUp(file) {
  565. console.log(file);
  566. },
  567. handleInit() {
  568. if (this.id) {
  569. this.handleQuery();
  570. } else {
  571. this.handleCreate();
  572. }
  573. },
  574. // 填报日期
  575. handleWrite(value) {
  576. if (value) {
  577. let range =
  578. new Date().getTime() > value.getTime()
  579. ? new Date().getTime()
  580. : value.getTime();
  581. this.pickOptions = {
  582. disabledDate(time) {
  583. return time.getTime() < range;
  584. },
  585. };
  586. } else {
  587. this.pickOptions = {
  588. disabledDate(time) {
  589. return time.getTime() < new Date().getTime() - 864000;
  590. },
  591. };
  592. }
  593. },
  594. handleEnd(value) {
  595. if (value) {
  596. this.pickWrite = {
  597. disabledDate(time) {
  598. return time.getTime() > value.getTime();
  599. },
  600. };
  601. if (
  602. this.superviseForm.write &&
  603. value.getTime() < this.superviseForm.write.getTime()
  604. ) {
  605. this.superviseForm.endTime = "";
  606. }
  607. } else {
  608. this.pickWrite = {
  609. disabledDate(time) {
  610. return time.getTime() - 864000 < new Date().getTime();
  611. },
  612. };
  613. }
  614. },
  615. // // 权限选择
  616. // handleRadio(e){
  617. // console.log(e,'e');
  618. // },
  619. handleAllow({ row, column }) {
  620. let public_permisson =
  621. (!this.form.permission_type ||
  622. this.status === "2" ||
  623. this.status === "3") &&
  624. this.type === "edit";
  625. let editable =
  626. this.row_list.includes(row) && this.column_list.includes(column);
  627. // let totalBoolean = (public_permisson || editable) && this.id;
  628. let totalBoolean = public_permisson || editable;
  629. return totalBoolean;
  630. },
  631. async handleQuery() {
  632. let url = "";
  633. let params = {};
  634. switch (this.attribute) {
  635. case "template":
  636. url = "/market/CMKFileTemplate/QueryCMKFileTemplateById";
  637. params = {
  638. templateId: this.id,
  639. };
  640. break;
  641. case "order":
  642. url = "/market/CMKIssued/CMKQueryIssuedById";
  643. params = {
  644. id: this.id,
  645. };
  646. break;
  647. case "file":
  648. url = "/market/CMKIssued/CMKIssuedProcessByUser";
  649. params = {
  650. id: this.id,
  651. receiverId: this.receiver,
  652. };
  653. break;
  654. }
  655. const {
  656. data: {
  657. templateContent,
  658. templateName,
  659. issuedId,
  660. templateId,
  661. list,
  662. superviseFlag,
  663. templateType,
  664. addFlag,
  665. distributeEndTime,
  666. distributeTime,
  667. distributeType,
  668. },
  669. } = await this.$http({
  670. url,
  671. method: "post",
  672. headers: {
  673. "Content-Type": "application/json",
  674. },
  675. data: params,
  676. });
  677. this.superviseFlag = superviseFlag;
  678. if (superviseFlag === "1") {
  679. this.superviseForm = {
  680. distribute: distributeType, // 派单周期
  681. write: distributeTime, // 填写周期
  682. endTime: distributeEndTime, // 截止时间
  683. };
  684. }
  685. this.templateType = templateType;
  686. this.template_id = templateId;
  687. this.issued_id = issuedId;
  688. this.addFlag = addFlag;
  689. console.log(JSON.parse(templateContent), "123123");
  690. if (list && list.length) {
  691. const { type } = list[0];
  692. if (type === "1") {
  693. // 公共权限
  694. // const { allowEditingColumns, rowNum } = list[0];
  695. this.form = {
  696. permission_type: Number(type) - 1,
  697. person: list.map((el) => {
  698. return `${el.principalMent}-${el.principalId},${el.principalName}`;
  699. }),
  700. charge: [
  701. {
  702. person: "",
  703. col_start: "",
  704. col_end: "",
  705. row_start: "",
  706. row_end: "",
  707. },
  708. ],
  709. };
  710. } else {
  711. // 特殊权限
  712. this.form = {
  713. permission_type: Number(type) - 1,
  714. col_start: "",
  715. col_end: "",
  716. row_start: "",
  717. row_end: "",
  718. charge: list.map((el) => ({
  719. person: `${el.principalMent}-${el.principalId},${el.principalName}`,
  720. col_start: el.allowEditingColumns.split(",")[0],
  721. col_end:
  722. el.allowEditingColumns.split(",")[
  723. el.allowEditingColumns.split(",").length - 1
  724. ],
  725. row_start: el.rowNum.split(",")[0],
  726. row_end: el.rowNum.split(",")[el.rowNum.split(",").length - 1],
  727. })),
  728. };
  729. }
  730. this.row_list =
  731. this.type === "edit" && list[0].rowNum
  732. ? list[0].rowNum
  733. .split(",")
  734. .map((element) => JSON.parse(element) - 1)
  735. : [];
  736. if (this.type === "edit" && list[0].allowEditingColumns) {
  737. // this.column_list = list[0].allowEditingColumns
  738. // .split(",")
  739. // .map((element) => JSON.parse(element) - 1);
  740. this.column_list =
  741. list[0].allowEditingColumnsFlag === "1"
  742. ? list[0].allowEditingColumnsShuzi
  743. .split(",")
  744. .map((element) => JSON.parse(element) - 1)
  745. : list[0].allowEditingColumns
  746. .split(",")
  747. .map((element) => JSON.parse(element) - 1);
  748. } else {
  749. this.column_list = [];
  750. }
  751. // this.formateNumber(list[0].allowEditingColumns);
  752. }
  753. this.handleCreate({
  754. json: templateContent ? JSON.parse(templateContent) : {},
  755. name: templateName,
  756. type: "json",
  757. });
  758. },
  759. handleSupervise(data) {
  760. if (data === "cancel") {
  761. this.supervise = false;
  762. this.superviseForm = {
  763. ...this.originSuperviseForm,
  764. };
  765. return;
  766. }
  767. if (this.supervise === false) {
  768. this.supervise = true;
  769. this.originSuperviseForm = {
  770. ...this.superviseForm,
  771. };
  772. } else {
  773. let filled =
  774. Object.keys(this.superviseForm).length === 3 &&
  775. Object.values(this.superviseForm).filter((el) => el !== "").length ===
  776. 3;
  777. if (filled) {
  778. let time = new Date().getTime();
  779. if (time > this.superviseForm.endTime.getTime()) {
  780. this.$message.error("截止时间不能小于当前时间");
  781. return;
  782. }
  783. this.superviseForm = {
  784. ...this.superviseForm,
  785. endTime: this.$formatDate(
  786. this.superviseForm.endTime,
  787. "YYYY-MM-DD HH:mm:ss"
  788. ), // 督办设置的截止时间
  789. write: this.$formatDate(this.superviseForm.write, "YYYY-MM-DD"), // 派发时间–或者叫—填报时间
  790. };
  791. this.supervise = false;
  792. } else {
  793. this.$message.error("请填写完整必要的信息");
  794. }
  795. }
  796. },
  797. handleForbid() {
  798. // const object = {};
  799. const { permission_type } = this.form;
  800. if (permission_type === 0) {
  801. // 公共权限 暂时不用可编辑行和列
  802. const { person } = this.form;
  803. if (person.length) {
  804. return false;
  805. }
  806. return true;
  807. } else if (permission_type === 1) {
  808. // 特殊权限
  809. let flag = 1;
  810. const { charge } = this.form;
  811. charge.forEach((el) => {
  812. if (
  813. Object.values(el).filter((v) => {
  814. return v !== "";
  815. }).length === 5
  816. ) {
  817. flag = flag * 1;
  818. } else {
  819. flag = flag * 0;
  820. }
  821. });
  822. return !flag;
  823. } else {
  824. return true;
  825. }
  826. },
  827. async handleCreate(data) {
  828. console.log(data);
  829. let that = this;
  830. const options = {
  831. container: "luckysheet",
  832. lang: "zh",
  833. total: "123",
  834. showsheetbar: true,
  835. hook: {
  836. // cellEditBefore: function () {
  837. // let time = new Date();
  838. // let hover = time.getHours();
  839. // let day = time.getDay();
  840. // if (day === 4 || day === 5 || day === 6 || day == 7 || day === 1) {
  841. // if ((day === 4 && hover <= 15) || (day === 1 && hover >= 15)) {
  842. // that.$message.error("不在可编辑时间");
  843. // return false;
  844. // }
  845. // } else {
  846. // that.$message.error("不在可编辑日期");
  847. // return false;
  848. // }
  849. // },
  850. },
  851. data: data,
  852. // hook: {
  853. // cellEditBefore: function ([
  854. // { row_focus: row, column_focus: column },
  855. // ]) {
  856. // if (!that.handleAllow({ row, column })) {
  857. // that.$message.error("您没有编辑权限");
  858. // }
  859. // },
  860. // // cellUpdated: function (row, column) {
  861. // // that.rowList.push(row);
  862. // // },
  863. // cellUpdateBefore: function (row, column) {
  864. // console.log(row, column);
  865. // if (!that.handleAllow({ row, column })) {
  866. // return false;
  867. // }
  868. // },
  869. // cellRenderAfter: function (cell, position) {
  870. // const { r: row, c: column } = position;
  871. // console.log();
  872. // if (cell) {
  873. // if (!that.handleAllow({ row, column })) {
  874. // cell.bg = "#d5d5d5";
  875. // } else {
  876. // cell.bg = "#ffffff";
  877. // }
  878. // }
  879. // },
  880. // rangePasteBefore: function ([
  881. // { row_focus: row, column_focus: column },
  882. // ]) {
  883. // if (!that.handleAllow({ row, column })) {
  884. // that.$message.error("您没有编辑权限");
  885. // return false;
  886. // }
  887. // },
  888. // updated: function ({ range }) {
  889. // const middle = range.map((el) => {
  890. // return that.paramsArr(el.row[0], el.row[1]);
  891. // });
  892. // let changedList = middle.join(",").split(",");
  893. // that.rowList.push(...changedList);
  894. // },
  895. // },
  896. };
  897. switch (data.type) {
  898. case "file":
  899. if (data.file) {
  900. await new Promise((resolve) => {
  901. luckyexcel.transformExcelToLucky(data.file, (export_json) => {
  902. options.data = [
  903. ...export_json.sheets.map((element) => ({
  904. ...element,
  905. zoomRatio: 0.75,
  906. })),
  907. ];
  908. options.title = export_json.info.name;
  909. resolve();
  910. });
  911. });
  912. }
  913. break;
  914. case "json":
  915. console.log(123);
  916. // if (json) {
  917. // options.data = [];
  918. // options.title = name;
  919. // }
  920. break;
  921. }
  922. window.luckysheet.create(options);
  923. let clock = setInterval(() => {
  924. if (window.luckysheet) {
  925. window.luckysheet.refresh();
  926. clearInterval(clock);
  927. }
  928. }, 1000);
  929. },
  930. async handleChange(response) {
  931. response.raw.total = "123";
  932. console.log(response);
  933. this.handleCreate({ file: response.raw, type: "file" });
  934. },
  935. //导出方法!!!!!
  936. async handleDownload() {
  937. Promise.all([
  938. await this.getMove(),
  939. await this.getMoveList(),
  940. await this.getUnicom(),
  941. await this.getUnicomList(),
  942. ]).then((res) => {
  943. let list = this.a.concat(this.b);
  944. exportExcel(list, "导出问卷");
  945. });
  946. },
  947. async handleAddAuth({ id }) {
  948. // const object = {};
  949. const { permission_type } = this.form;
  950. console.log(id, permission_type);
  951. let reqdata = {
  952. templateId: id,
  953. type: permission_type ? 2 : 1,
  954. };
  955. if (!permission_type) {
  956. // 公共权限
  957. const { person } = this.form;
  958. const principalId = [];
  959. const principalName = [];
  960. const principalMent = [];
  961. person.forEach((el) => {
  962. principalMent.push(el.split(",")[0].split("-")[0]);
  963. principalId.push(el.split(",")[0].split("-")[1]);
  964. principalName.push(el.split(",")[1]);
  965. });
  966. reqdata.principalId = principalId.join(",");
  967. reqdata.principalName = principalName.join(",");
  968. reqdata.principalMent = principalMent.join(",");
  969. } else {
  970. const { charge } = this.form;
  971. // 特殊权限
  972. reqdata.specialAuth = charge.map((el) =>
  973. JSON.stringify({
  974. allowEditingColumns: `${el.col_start},${el.col_end}`,
  975. rowNum: `${el.row_start},${el.row_end}`,
  976. principalMent: el.person.split(",")[0].split("-")[0],
  977. principalId: el.person.split(",")[0].split("-")[1],
  978. principalName: el.person.split(",")[1],
  979. })
  980. );
  981. }
  982. const {
  983. data: { result, desc },
  984. } = await this.$http({
  985. url: this.id
  986. ? "/market/CMKFileTemplateAuthority/CMKFileTemplateAuthorityUpdate"
  987. : "/market/CMKFileTemplateAuthority/CMKFileTemplateAuthorityAdd",
  988. method: "post",
  989. headers: {
  990. "Content-Type": "application/json",
  991. },
  992. data: reqdata,
  993. });
  994. if (result) {
  995. this.$message.error(desc);
  996. } else {
  997. this.$message.success(desc);
  998. }
  999. return result;
  1000. },
  1001. async handleSave(type) {
  1002. let edit_url = "";
  1003. switch (this.attribute) {
  1004. case "template":
  1005. edit_url = "";
  1006. break;
  1007. case "order":
  1008. edit_url = "";
  1009. break;
  1010. case "file":
  1011. edit_url = "/market/CMKIssued/CMKIssuedSubmit";
  1012. break;
  1013. }
  1014. const sheet_name = window.luckysheet.getSheet().name;
  1015. const data = window.luckysheet.getSheet(sheet_name);
  1016. const workbook_name = window.luckysheet.getWorkbookName();
  1017. if (!this.id) {
  1018. // 新增时添加权限
  1019. let value = {};
  1020. if (!this.templateType) {
  1021. this.$message.error("请输入模板类型");
  1022. return;
  1023. }
  1024. if (
  1025. Object.values(this.superviseForm).filter((el) => el !== "").length ===
  1026. 3
  1027. ) {
  1028. value = {
  1029. distributeEndTime: this.superviseForm.endTime, // 督办设置的截止时间
  1030. distributeTime: this.superviseForm.write, // 派发时间–或者叫—填报时间
  1031. distributeType: this.superviseForm.distribute, //派发周期类型 派发周期类型 0.月 1.季度 2.半年 3.年
  1032. superviseFlag: 1, //督办标识 0.不是 1.是
  1033. templateType: this.templateType, //模板类型
  1034. templateContent: JSON.stringify(data), //文件内容
  1035. templateName: workbook_name, //模板名称
  1036. templateUrl: "", //文件链接
  1037. status: type,
  1038. };
  1039. } else {
  1040. value = {
  1041. superviseFlag: 0, //督办标识 0.不是 1.是
  1042. templateType: this.templateType, //模板类型
  1043. templateContent: JSON.stringify(data), //文件内容
  1044. templateName: workbook_name, //模板名称
  1045. templateUrl: "", //文件链接
  1046. status: type,
  1047. };
  1048. }
  1049. const {
  1050. data: { body },
  1051. } = await this.$http({
  1052. url: "/market/CMKFileTemplate/CMKFileTemplateAdd", // 新增
  1053. method: "post",
  1054. headers: {
  1055. "Content-Type": "application/json",
  1056. },
  1057. data: value,
  1058. });
  1059. await this.handleAddAuth({ id: body });
  1060. this.$emit("save");
  1061. } else {
  1062. // 职位
  1063. let duty = JSON.parse(sessionStorage.userInfo).duty;
  1064. if (duty === "7" && type === "0") {
  1065. this.manager_approve = true;
  1066. } else {
  1067. if (type === "2") {
  1068. // 暂存
  1069. let value = {};
  1070. if (!this.templateType) {
  1071. this.$message.error("请输入模板类型");
  1072. return;
  1073. }
  1074. if (
  1075. Object.values(this.superviseForm).filter((el) => el !== "")
  1076. .length === 3
  1077. ) {
  1078. value = {
  1079. templateId: this.id,
  1080. distributeEndTime: this.superviseForm.endTime, // 督办设置的截止时间
  1081. distributeTime: this.superviseForm.write, // 派发时间–或者叫—填报时间
  1082. distributeType: this.superviseForm.distribute, //派发周期类型 派发周期类型 0.月 1.季度 2.半年 3.年
  1083. superviseFlag: 1, //督办标识 0.不是 1.是
  1084. templateType: this.templateType, //模板类型
  1085. templateContent: JSON.stringify(data), //文件内容
  1086. templateName: workbook_name, //模板名称
  1087. templateUrl: "", //文件链接
  1088. status: type,
  1089. };
  1090. } else {
  1091. value = {
  1092. templateId: this.id,
  1093. superviseFlag: 0, //督办标识 0.不是 1.是
  1094. templateType: this.templateType, //模板类型
  1095. templateContent: JSON.stringify(data), //文件内容
  1096. templateName: workbook_name, //模板名称
  1097. templateUrl: "", //文件链接
  1098. status: type,
  1099. };
  1100. }
  1101. await this.$http({
  1102. url: "/market/CMKFileTemplate/UptateCMKFileTemplateById", //
  1103. method: "post",
  1104. headers: {
  1105. "Content-Type": "application/json",
  1106. },
  1107. data: value,
  1108. });
  1109. this.$emit("save");
  1110. return;
  1111. }
  1112. // 员工提交
  1113. this.rowList.shift();
  1114. let reqdata = {
  1115. rowIndex: [...new Set(this.rowList)]
  1116. .sort(function (a, b) {
  1117. return a - b;
  1118. })
  1119. .join(","),
  1120. rowContent: [...new Set(this.rowList)]
  1121. .sort(function (a, b) {
  1122. return a - b;
  1123. })
  1124. .map((el) => {
  1125. return data.data[el];
  1126. }),
  1127. };
  1128. await this.$http({
  1129. url: edit_url, //提交
  1130. method: "post",
  1131. headers: {
  1132. "Content-Type": "application/json",
  1133. },
  1134. data: {
  1135. id: this.template_id,
  1136. templateContent: JSON.stringify(data),
  1137. templateName: workbook_name,
  1138. issuedId: this.issued_id,
  1139. rowJson: JSON.stringify(reqdata),
  1140. },
  1141. });
  1142. this.$emit("save");
  1143. }
  1144. }
  1145. },
  1146. // 判断数组是否有值
  1147. confirmArrayData(data) {
  1148. if (data instanceof Array) {
  1149. let flag = 0;
  1150. if (data.length) {
  1151. data.forEach((el) => {
  1152. if (el instanceof Object) {
  1153. flag = flag + 1;
  1154. }
  1155. });
  1156. if (flag) {
  1157. return true;
  1158. } else {
  1159. return false;
  1160. }
  1161. } else {
  1162. return false;
  1163. }
  1164. } else {
  1165. return false;
  1166. }
  1167. },
  1168. async handleAuth() {
  1169. this.$refs["form"].validate((valid) => {
  1170. if (valid) {
  1171. if (this.handleForbid()) {
  1172. this.$message.error("请完善可编辑信息");
  1173. return false;
  1174. }
  1175. if (this.id) {
  1176. this.handleAddAuth({ id: this.id });
  1177. }
  1178. this.handleVisible();
  1179. }
  1180. });
  1181. },
  1182. // 通用方法用于转化全局
  1183. paramsArr(start, end) {
  1184. const arr = [];
  1185. console.log(start, end);
  1186. for (let i = Number(start); i <= Number(end); i++) {
  1187. arr.push(i);
  1188. }
  1189. return arr.join(",");
  1190. },
  1191. filterName(id, arr) {
  1192. return arr.filter((el) => el.secLeaderLogin === id)[0].secLeaderName;
  1193. },
  1194. handleCharge(type) {
  1195. switch (type) {
  1196. case "add":
  1197. this.form.charge.push({
  1198. person: "",
  1199. });
  1200. this.handleForbid();
  1201. break;
  1202. case "delete":
  1203. this.form.charge.pop();
  1204. this.handleForbid();
  1205. break;
  1206. }
  1207. },
  1208. handleVisible() {
  1209. this.visible = !this.visible;
  1210. },
  1211. handleInput(index, name, value) {
  1212. let reg = /^[0-9]*$/;
  1213. if (!reg.test(value)) {
  1214. this.form.charge[index][name] = this.form.charge[index][name].substr(
  1215. 0,
  1216. this.form.charge[index][name].length - 1
  1217. );
  1218. this.$message.error("该处只能填写数字");
  1219. }
  1220. },
  1221. async handleApprove(type) {
  1222. if (type) {
  1223. if (this.approveForm.type) {
  1224. if (this.approveForm.type === "3" && !this.approveForm.comments) {
  1225. this.$message.error("请输入其他审批意见");
  1226. return;
  1227. }
  1228. } else {
  1229. this.$message.error("请选择审批意见");
  1230. return;
  1231. }
  1232. const sheet_name = window.luckysheet.getSheet().name;
  1233. const data = window.luckysheet.getSheet(sheet_name);
  1234. const workbook_name = window.luckysheet.getWorkbookName();
  1235. // 经理提交
  1236. this.rowList.shift();
  1237. let reqdata = {
  1238. rowIndex: [...new Set(this.rowList)]
  1239. .sort(function (a, b) {
  1240. return a - b;
  1241. })
  1242. .join(","),
  1243. rowContent: [...new Set(this.rowList)]
  1244. .sort(function (a, b) {
  1245. return a - b;
  1246. })
  1247. .map((el) => {
  1248. return data.data[el];
  1249. }),
  1250. };
  1251. await this.$http({
  1252. url: "/market/CMKIssued/CMKIssuedSubmit", // 提交
  1253. method: "post",
  1254. headers: {
  1255. "Content-Type": "application/json",
  1256. },
  1257. data: {
  1258. id: this.template_id,
  1259. templateContent: JSON.stringify(data),
  1260. templateName: workbook_name,
  1261. issuedId: this.issued_id,
  1262. rowJson: JSON.stringify(reqdata),
  1263. },
  1264. });
  1265. let params = {
  1266. id: this.issued_id,
  1267. reviewOpinion:
  1268. this.approveForm.type === "3"
  1269. ? this.approveForm.comments
  1270. : this.approveForm.type,
  1271. };
  1272. switch (type) {
  1273. case "1":
  1274. params = {
  1275. ...params,
  1276. operateName: "结束",
  1277. status: 3,
  1278. };
  1279. break;
  1280. case "4":
  1281. params = {
  1282. ...params,
  1283. operateName: "转副总审批",
  1284. reviewType: 2,
  1285. };
  1286. break;
  1287. case "3":
  1288. params = {
  1289. ...params,
  1290. operateName: "转总经理审批",
  1291. reviewType: 3,
  1292. };
  1293. break;
  1294. }
  1295. await this.$http({
  1296. url: "/market/CMKIssued/CMKIssuedCheck", // 审批
  1297. method: "post",
  1298. headers: {
  1299. "Content-Type": "application/json",
  1300. },
  1301. data: params,
  1302. });
  1303. this.$message({
  1304. type: "success",
  1305. message: "审批成功",
  1306. });
  1307. this.manager_approve = false;
  1308. this.$emit("save");
  1309. } else {
  1310. this.manager_approve = false;
  1311. }
  1312. },
  1313. handleFullscreen() {
  1314. const element = document.body;
  1315. const is_fullscreen =
  1316. document.fullScreen ||
  1317. document.mozFullScreen ||
  1318. document.webkitIsFullScreen;
  1319. if (!is_fullscreen) {
  1320. //进入全屏,多重短路表达式
  1321. (element.requestFullscreen && element.requestFullscreen()) ||
  1322. (element.mozRequestFullScreen && element.mozRequestFullScreen()) ||
  1323. (element.webkitRequestFullscreen &&
  1324. element.webkitRequestFullscreen()) ||
  1325. (element.msRequestFullscreen && element.msRequestFullscreen());
  1326. } else {
  1327. //退出全屏,三目运算符
  1328. document.exitFullscreen
  1329. ? document.exitFullscreen()
  1330. : document.mozCancelFullScreen
  1331. ? document.mozCancelFullScreen()
  1332. : document.webkitExitFullscreen
  1333. ? document.webkitExitFullscreen()
  1334. : "";
  1335. }
  1336. },
  1337. handleResave() {
  1338. const sheet_name = window.luckysheet.getSheet().name;
  1339. let baseUrl = "";
  1340. const datas = window.luckysheet.getSheet(sheet_name);
  1341. // switch (datas.subScript) {
  1342. // case 0:
  1343. // baseUrl = "expensesUnicom";
  1344. // break;
  1345. // case 1:
  1346. // baseUrl = "questionnaireUnicom";
  1347. // break;
  1348. // case 2:
  1349. // baseUrl = "expensesTelecom";
  1350. // datas.index = 2;
  1351. // break;
  1352. // case 3:
  1353. // baseUrl = "questionnaireTelecom";
  1354. // }
  1355. switch (datas.name) {
  1356. case '联通资费内容':
  1357. baseUrl = "expensesUnicom";
  1358. break;
  1359. case '联通问卷内容':
  1360. baseUrl = "questionnaireUnicom";
  1361. break;
  1362. case '电信资费内容':
  1363. baseUrl = "expensesTelecom";
  1364. break;
  1365. case '电信问卷内容':
  1366. baseUrl = "questionnaireTelecom";
  1367. }
  1368. const workbook_name = window.luckysheet.getWorkbookName();
  1369. let value = {};
  1370. if (
  1371. Object.values(this.superviseForm).filter((el) => el !== "").length === 3
  1372. ) {
  1373. value = {
  1374. templateId: this.id,
  1375. distributeEndTime: this.superviseForm.endTime, // 督办设置的截止时间
  1376. distributeTime: this.superviseForm.write, // 派发时间–或者叫—填报时间
  1377. distributeType: this.superviseForm.distribute, //派发周期类型 派发周期类型 0.月 1.季度 2.半年 3.年
  1378. superviseFlag: 1, //督办标识 0.不是 1.是
  1379. templateType: this.templateType, //模板类型
  1380. mKcompetitor: JSON.parse(datas), //文件内容
  1381. templateName: workbook_name, //模板名称
  1382. templateUrl: "", //文件链接
  1383. status: "0",
  1384. };
  1385. } else {
  1386. let data = datas;
  1387. // data.id = this.id;
  1388. // data.fileName = window.luckysheet.getWorkbookName();
  1389. // data.powerFlag = 1;
  1390. // data.powerFlagDev = "关";
  1391. // data.tempType = this.templateType;
  1392. // data.colHeaderNum = 1;
  1393. // data.tempTypeDesc = "";
  1394. value = {
  1395. // templateId: this.id,
  1396. // superviseFlag: 0, //督办标识 0.不是 1.是
  1397. // templateType: this.templateType, //模板类型
  1398. data: data, //文件内容
  1399. // templateName: workbook_name, //模板名称
  1400. // templateUrl: "", //文件链接
  1401. // status: "0",
  1402. };
  1403. }
  1404. this.$http({
  1405. // 联通资费内容
  1406. // url: "/market/expensesUnicom/save",
  1407. //联通问卷
  1408. // url: "/market/questionnaireUnicom/save",
  1409. //电信费用
  1410. // url: "/market/expensesTelecom/save",
  1411. //电信问卷
  1412. // url: "/market/questionnaireTelecom/save",
  1413. url: "/market/" + baseUrl + "/save",
  1414. method: "post",
  1415. headers: {
  1416. "Content-Type": "application/json",
  1417. },
  1418. data: value,
  1419. }).then(() => {
  1420. this.$message({
  1421. type: "success",
  1422. message: "保存成功",
  1423. });
  1424. this.getCheck();
  1425. });
  1426. },
  1427. handleChargeList() {
  1428. this.$http({
  1429. url: "/market/techcentergj/queryLeaderList",
  1430. method: "post",
  1431. headers: {
  1432. "Content-Type": "application/json",
  1433. },
  1434. data: {},
  1435. }).then((response) => {
  1436. this.charge_list = response.data.map((element) => ({
  1437. label: `${element.ou} ${element.secLeaderName}`,
  1438. value: `${element.ou}-${element.secLeaderLogin},${element.secLeaderName}`,
  1439. }));
  1440. });
  1441. },
  1442. },
  1443. mounted() {
  1444. this.getJurisdiction();
  1445. this.handleInit();
  1446. // this.handleChargeList();
  1447. },
  1448. destroyed() {
  1449. window.luckysheet.destroy();
  1450. },
  1451. };
  1452. </script>
  1453. <style lang="scss" scope>
  1454. .el-dialog {
  1455. width: 100%;
  1456. height: 100%;
  1457. margin-top: 0 !important;
  1458. }
  1459. .sheet-container {
  1460. position: fixed;
  1461. width: calc(100% - 40px);
  1462. height: 100%;
  1463. &-block {
  1464. overflow: hidden;
  1465. position: absolute;
  1466. width: 100%;
  1467. height: 75%;
  1468. }
  1469. &-require {
  1470. color: red;
  1471. }
  1472. .el-input {
  1473. width: 200px;
  1474. margin-right: 10px;
  1475. }
  1476. }
  1477. .form {
  1478. &-input {
  1479. margin-top: 5px;
  1480. .el-input {
  1481. width: 150px;
  1482. .el-input__inner {
  1483. height: 30px !important;
  1484. line-height: 30px !important;
  1485. }
  1486. }
  1487. }
  1488. &-content {
  1489. margin: 0px 10px;
  1490. }
  1491. &-select {
  1492. .el-input {
  1493. width: 100px;
  1494. .el-input__inner {
  1495. height: 30px !important;
  1496. line-height: 30px !important;
  1497. }
  1498. }
  1499. }
  1500. }
  1501. </style>