notShow.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. // 不显示的信息点数组
  2. import text from "@/utils/handsontable/mainText"
  3. import tools from "@/utils/scan/tools"
  4. import fieldData from "@/utils/handsontable/fillterField"
  5. import dataTypeMap from "./dataTypeMap"
  6. //在编辑模式下并且勾选隐藏自动填充的信息点不显示的字段
  7. let noShowArr = [
  8. "specification",
  9. "serviceLife"
  10. ]
  11. //在编辑模式下不显示的字段
  12. let cantShow = [
  13. "EquipQRCode",
  14. "EquipID",
  15. "EquipName",
  16. "BIMLocation",
  17. "Brand",
  18. "Specification",
  19. "Manufacturer",
  20. "Supplier",
  21. "SupplierContactor",
  22. "SupplierPhone",
  23. "SupplierEmail",
  24. "SupplierWeb",
  25. "SupplierFax",
  26. "Maintainer",
  27. "MaintainerContactor",
  28. "MaintainerPhone",
  29. "MaintainerEmail",
  30. "MaintainerWeb",
  31. "Principal",
  32. "MaintainerFax",
  33. "Insurer",
  34. "InsurerContactor",
  35. "InsurerPhone",
  36. "InsurerEmail",
  37. "InsurerWeb",
  38. "InsurerFax",
  39. "InsuranceFile",
  40. "EquipID",
  41. "EquipName",
  42. "SpaceCount",
  43. "SpaceList",
  44. "TenantID",
  45. "ShaftID"
  46. ]
  47. //台账编辑页面不显示的厂商信息
  48. let firmArr = [
  49. "brand", //品牌
  50. "specification", //设备型号
  51. "manufacturer", //生产厂家
  52. "supplier", //供应商单位名称
  53. "supplierContactor", //供应商联系人
  54. "supplierPhone", //供应商联系电话
  55. "supplierEmail", //供应商电子邮件
  56. "supplierWeb", //供应商网址
  57. "supplierFax", //供应商传真
  58. "maintainer", //维修商单位名称
  59. "maintainerContactor", //维修商联系人
  60. "maintainerPhone", //维修商联系电话
  61. "maintainerEmail", //维修商电子邮件
  62. "maintainerWeb", //维修商网址
  63. "maintainerFax", //维修商传真
  64. "insurer", //保险公司名称
  65. "insurerContactor", //保险公司联系人
  66. "insurerPhone", //保险公司联系电话
  67. 'insurerEmail', //保险公司电子邮件
  68. "insurerWeb", //保险公司网址
  69. "insurerFax", //保险公司传真
  70. // "dpManufacturerId",//品牌型号Id
  71. // "dpSupplierId",//供应商信息Id
  72. // "dpMaintainerId",//维修商信息Id
  73. // "dpInsurerId"//保险公司信息Id
  74. ]
  75. // 将映射表枚举值转为数组
  76. const mapToArr = () => {
  77. const arr = []
  78. for(let key in dataTypeMap) {
  79. arr.push(dataTypeMap[key])
  80. }
  81. return arr;
  82. }
  83. const showTools = {
  84. inputModeArr: mapToArr(),
  85. cantShow: (code) => {
  86. let falg = true
  87. cantShow.map(item => {
  88. if (item == code) {
  89. falg = false
  90. }
  91. })
  92. return falg
  93. },
  94. fixedNoShowField: (noShowList, code) => {
  95. let flag = true
  96. noShowList.map(item => {
  97. if (item == code) {
  98. flag = false
  99. }
  100. })
  101. return flag
  102. },
  103. isShow: (code) => {
  104. let falg = true
  105. noShowArr.map(item => {
  106. if (item == code) {
  107. falg = false
  108. }
  109. })
  110. return falg
  111. },
  112. arrToArr(arr, showType) {
  113. let first = 0,
  114. scound = 0,
  115. three = 0,
  116. four = 0
  117. arr.find(function (value, index, arr) {
  118. let flag = (showType != "Visible" || value.visible)
  119. if (
  120. ((value.code == "brand" && flag) ||
  121. (value.code == "specification" && flag) ||
  122. (value.code == "manufacturer" && flag)) && !first
  123. ) {
  124. first = index
  125. }
  126. if (
  127. ((value.code == "supplier" && flag) ||
  128. (value.code == "supplierContactor" && flag) ||
  129. (value.code == "supplierEmail" && flag) ||
  130. (value.code == "supplierWeb" && flag) ||
  131. (value.code == "supplierFax" && flag) ||
  132. (value.code == "supplierPhone" && flag)) && !scound
  133. ) {
  134. scound = index
  135. }
  136. if (
  137. ((value.code == "maintainer" && flag) ||
  138. (value.code == "maintainerContactor" && flag) ||
  139. (value.code == "maintainerPhone" && flag) ||
  140. (value.code == "maintainerEmail" && flag) ||
  141. (value.code == "maintainerWeb" && flag) ||
  142. (value.code == "maintainerFax" && flag)) && !three
  143. ) {
  144. three = index
  145. }
  146. if (
  147. ((value.code == "insurer" && flag) ||
  148. (value.code == "insurerContactor" && flag) ||
  149. (value.code == "insurerPhone" && flag) ||
  150. (value.code == "insurerEmail" && flag) ||
  151. (value.code == "insurerWeb" && flag) ||
  152. (value.code == "insurerFax" && flag)) && !four
  153. ) {
  154. four = index
  155. }
  156. })
  157. let numList = [first, scound, three, four]
  158. numList.reverse().map((item, index) => {
  159. if (item) {
  160. if (index == 0) {
  161. arr.splice(item, 0, {
  162. category: 'STATIC',
  163. dataType: "STRING",
  164. firstName: "基本信息",
  165. aliasCode: "dpInsurerId",
  166. aliasName: "保险公司信息",
  167. name: "保险公司信息",
  168. code: "dpInsurerId",
  169. origCode: "dpInsurerId",
  170. origDataType: "Str",
  171. path: "dpInsurerId",
  172. priority: "S",
  173. editable: true,
  174. visible: true
  175. })
  176. } else if (index == 1) {
  177. arr.splice(item, 0, {
  178. category: 'STATIC',
  179. dataType: "STRING",
  180. firstName: "基本信息",
  181. aliasCode: "dpMaintainerId",
  182. aliasName: "维修商信息",
  183. name: "维修商信息",
  184. code: "dpMaintainerId",
  185. origCode: "dpMaintainerId",
  186. origDataType: "Str",
  187. path: "dpMaintainerId",
  188. priority: "S",
  189. editable: true,
  190. visible: true
  191. })
  192. } else if (index == 2) {
  193. arr.splice(item, 0, {
  194. category: 'STATIC',
  195. dataType: "STRING",
  196. firstName: "基本信息",
  197. aliasCode: "dpSupplierId",
  198. aliasName: "供应商信息",
  199. name: "供应商信息",
  200. code: "dpSupplierId",
  201. origCode: "dpSupplierId",
  202. origDataType: "Str",
  203. path: "dpSupplierId",
  204. priority: "S",
  205. editable: true,
  206. visible: true
  207. })
  208. } else if (index == 3) {
  209. arr.splice(item, 0, {
  210. category: 'STATIC',
  211. dataType: "STRING",
  212. firstName: "基本信息",
  213. aliasCode: "dpManufacturerId",
  214. aliasName: "生产厂家/品牌/型号",
  215. name: "生产厂家/品牌/型号",
  216. code: "dpManufacturerId",
  217. origCode: "dpManufacturerId",
  218. origDataType: "Str",
  219. path: "dpManufacturerId",
  220. priority: "S",
  221. editable: true,
  222. visible: true
  223. })
  224. }
  225. }
  226. })
  227. return arr
  228. },
  229. /**
  230. *
  231. * @param {*} arr 原始表头数组
  232. * @param {*} type 对应表格的模块类型
  233. * @param {*} onlyRead 是否只读
  234. * @param {*} showType 查看类型(全部;只看要采集的信息;隐藏部分信息)
  235. * @param {*} taizhang 是否是台账类型(默认为false)
  236. *
  237. */
  238. headerTextFilter(arr, type, onlyRead, showType, taizhang = false) {
  239. // if (taizhang && !onlyRead) {
  240. // arr = this.arrToArr(arr, showType)
  241. // }
  242. let data = arr.map(item => {
  243. // if (type == "property" && item.firstTag == "RunParam") { //资产台账不显示运行参数
  244. // return undefined
  245. // }
  246. if (onlyRead) { //只读模式
  247. if (!this.filterUnshow(onlyRead, type, item.code)) { //过滤固定不显示字段
  248. return undefined
  249. }
  250. if (showType == "Visible" && item.visible) { //只看要采集的信息
  251. return this.isUnit(item)
  252. } else if (showType == "all") { //显示全部
  253. return this.isUnit(item)
  254. } else {
  255. return undefined
  256. }
  257. } else { //编辑模式
  258. // if (taizhang && !this.filterFirm(item.code)) {
  259. // return undefined
  260. // }
  261. if (!this.filterUnshow(onlyRead, type, item.code)) { //过滤固定不显示字段
  262. return undefined
  263. }
  264. if (showType == "Visible" && item.visible) { //只看要采集的信息
  265. return this.isUnit(item)
  266. } else if (showType == "all") { //显示全部
  267. return this.isUnit(item)
  268. } else if (showType == "partInfo" && item.visible && this.isShow(item.code)) { //隐藏部分厂家信息(***需维护不显示列表***)
  269. // if (item.FirstName == "控制参数" || item.FirstName == "设定参数" || item.FirstName == "运行参数") {
  270. if (item.firstTag == "techParam") { //技术参数
  271. return undefined
  272. } else {
  273. return this.isUnit(item)
  274. }
  275. } else {
  276. return undefined
  277. }
  278. }
  279. }).filter(d => d)
  280. return data
  281. },
  282. headerTypeFilter(arr, type, onlyRead, showType, taizhang = false) {
  283. // if (taizhang && !onlyRead) {
  284. // arr = this.arrToArr(arr, showType)
  285. // }
  286. text.readOnly = onlyRead;
  287. let data = arr.map(item => {
  288. // if (type == "property" && item.firstTag == "runParam") { //资产台账不显示运行参数
  289. // return undefined
  290. // }
  291. if (onlyRead) { //只读模式
  292. if (!this.filterUnshow(onlyRead, type, item.code)) { //过滤固定不显示字段
  293. return undefined
  294. }
  295. if (showType == "Visible" && item.visible) { //只看要采集的信息
  296. return this.textFormat(item, onlyRead)
  297. } else if (showType == "all") { //显示全部
  298. return this.textFormat(item, onlyRead)
  299. } else {
  300. return undefined
  301. }
  302. } else { //编辑模式
  303. // if (taizhang && !this.filterFirm(item.code)) {
  304. // return undefined
  305. // }
  306. if (!this.filterUnshow(onlyRead, type, item.code)) { //过滤固定不显示字段
  307. return undefined
  308. }
  309. if (showType == "Visible" && item.visible) { //只看要采集的信息
  310. return this.inputModeFilter(item, onlyRead)
  311. } else if (showType == "all") { //显示全部
  312. return this.inputModeFilter(item, onlyRead)
  313. } else if (showType == "partInfo" && item.visible && this.isShow(item.code)) { //隐藏部分厂家信息(***需维护不显示列表***)
  314. // if (item.FirstName == "控制参数" || item.FirstName == "设定参数" || item.FirstName == "运行参数") {
  315. if (item.firstTag == "techParam") { //技术参数
  316. return undefined
  317. } else {
  318. return this.inputModeFilter(item, onlyRead)
  319. }
  320. } else {
  321. return undefined
  322. }
  323. }
  324. }).filter(d => d)
  325. return data
  326. },
  327. isUnit(item) {
  328. if (!item.unit || item.unit == "") {
  329. return item.name;
  330. } else {
  331. return item.name + "(" + item.unit + ")";
  332. }
  333. },
  334. textFormat(item, onlyRead) {
  335. if (
  336. // item.code == "EquipQRCode" ||
  337. // item.code == "RoomQRCode"
  338. item.code == "defaultQRCode"
  339. ) {
  340. return {
  341. data: item.path,
  342. renderer: text.lookQRCode,
  343. readOnly: onlyRead
  344. }
  345. }
  346. //图片类型
  347. if (
  348. item.code == "installPic" ||
  349. item.code == "nameplate" ||
  350. item.code == "pic"
  351. ) {
  352. return {
  353. data: item.path,
  354. renderer: text.picType,
  355. readOnly: onlyRead
  356. }
  357. }
  358. //文件类型
  359. if (item.code == "insuranceFile" ||
  360. item.code == "archive" ||
  361. item.code == "checkReport" ||
  362. item.code == "maintainManual" ||
  363. item.code == "approachingAcceptance" ||
  364. item.code == "acceptanceReport" ||
  365. item.code == "operationManual" ||
  366. item.code == "originalCertificate" ||
  367. item.code == "testReport" ||
  368. item.code == "productCertification" ||
  369. item.code == "installInstruction" ||
  370. item.code == "supplierContract" ||
  371. item.code == "drawing" ||
  372. item.code == "installDrawing"
  373. ) {
  374. return {
  375. data: item.path,
  376. renderer: text.fileType,
  377. readOnly: onlyRead
  378. }
  379. }
  380. if (item.category == 'STATIC') {
  381. if (item.dataType == dataTypeMap.ENUM || item.dataType == dataTypeMap.BOOLEAN) { //单选输入
  382. return {
  383. data: item.path,
  384. renderer: tools.customDropdownRenderer,
  385. editor: "chosen",
  386. readOnly: onlyRead,
  387. chosenOptions: {
  388. data: item.dataSource ? tools.formatDataSource(item.dataSource) : ""
  389. }
  390. };
  391. } else if (item.dataType == dataTypeMap.DOUBLE || item.dataType == dataTypeMap.INTEGER) { // 数字输入
  392. return {
  393. data: item.path,
  394. renderer: tools.customDropdownRenderer,
  395. editor: "chosen",
  396. readOnly: onlyRead,
  397. chosenOptions: {
  398. multiple: true, //多选
  399. data: item.dataSource ? tools.formatDataSource(item.dataSource) : ""
  400. }
  401. };
  402. } else if (item.dataType == dataTypeMap.DOUBLE || item.dataType == dataTypeMap.INTEGER) { // 数字输入
  403. return {
  404. data: item.path,
  405. type: "numeric",
  406. readOnly: onlyRead,
  407. numericFormat: {
  408. pattern: "0,0.00"
  409. }
  410. };
  411. } else if (item.dataType == dataTypeMap.DATETIME) { // 日期输入
  412. return {
  413. data: item.path,
  414. type: "date",
  415. dateFormat: "YYYYMMDDHHmmss",
  416. readOnly: onlyRead,
  417. correctFormat: true
  418. };
  419. } else if (item.dataType == dataTypeMap.STRING) { // 文本输入
  420. return {
  421. data: item.path,
  422. readOnly: onlyRead
  423. }
  424. } else { //(未支持的输入方式)暂不支持编辑
  425. return {
  426. data: item.path,
  427. readOnly: onlyRead
  428. }
  429. }
  430. } else {// 动态信息点
  431. // console.log(`%c${item.category}-${item.dataType}`,`color:#c215e1;font-size: 20px;background:#434101`);
  432. return {
  433. data: item.path,
  434. readOnly: !item.editable
  435. }
  436. }
  437. },
  438. inputModeFilter(item, onlyRead) {
  439. if (
  440. // item.code == "EquipQRCode" ||
  441. // item.code == "RoomQRCode"
  442. item.code == "defaultQRCode"
  443. ) {
  444. return {
  445. data: item.path,
  446. renderer: text.lookQRCode,
  447. readOnly: !item.editable
  448. }
  449. }
  450. //图片类型
  451. if (
  452. item.code == "installPic" ||
  453. item.code == "nameplate" ||
  454. item.code == "pic"
  455. ) {
  456. return {
  457. data: item.path,
  458. renderer: text.picType,
  459. readOnly: !item.editable
  460. }
  461. }
  462. //文件类型
  463. if (item.code == "insuranceFile" ||
  464. item.code == "archive" ||
  465. item.code == "checkReport" ||
  466. item.code == "maintainManual" ||
  467. item.code == "approachingAcceptance" ||
  468. item.code == "acceptanceReport" ||
  469. item.code == "operationManual" ||
  470. item.code == "originalCertificate" ||
  471. item.code == "testReport" ||
  472. item.code == "productCertification" ||
  473. item.code == "installInstruction" ||
  474. item.code == "supplierContract" ||
  475. item.code == "drawing" ||
  476. item.code == "installDrawing"
  477. ) {
  478. return {
  479. data: item.path,
  480. renderer: text.fileType,
  481. readOnly: !item.editable
  482. }
  483. }
  484. //四大厂商
  485. // if (
  486. // item.code == "dpSupplierId" ||
  487. // item.code == "dpMaintainerId" ||
  488. // item.code == "dpInsurerId" ||
  489. // item.code == "dpManufacturerId"
  490. // ) {
  491. // return {
  492. // data: item.path,
  493. // renderer: text.idType,
  494. // readOnly: !item.editable
  495. // }
  496. // }
  497. if (!item.category) {
  498. console.log('新版字典无输入类型', item)
  499. }
  500. if (item.category == 'STATIC') {
  501. if (item.dataType == dataTypeMap.ENUM || item.dataType == dataTypeMap.BOOLEAN) { //单选输入
  502. return {
  503. data: item.path,
  504. renderer: tools.customDropdownRenderer,
  505. editor: "chosen",
  506. readOnly: !item.editable,
  507. chosenOptions: {
  508. data: item.dataSource ? tools.formatDataSource(item.dataSource) : ""
  509. }
  510. };
  511. } else if (item.dataType == dataTypeMap.MENUM) { //多选输入
  512. return {
  513. data: item.path,
  514. renderer: tools.customDropdownRenderer,
  515. editor: "chosen",
  516. readOnly: !item.editable,
  517. chosenOptions: {
  518. multiple: true, //多选
  519. data: item.dataSource ? tools.formatDataSource(item.dataSource) : ""
  520. }
  521. };
  522. } else if (item.dataType == dataTypeMap.DOUBLE || item.dataType == dataTypeMap.INTEGER) { // 数字输入
  523. return {
  524. data: item.path,
  525. type: "numeric",
  526. readOnly: !item.editable,
  527. numericFormat: {
  528. pattern: "0,0.00"
  529. }
  530. };
  531. } else if (item.dataType == dataTypeMap.DATETIME) { // 日期输入
  532. return {
  533. data: item.path,
  534. type: "date",
  535. dateFormat: item.formater || "YYYYMMDDHHmmss",
  536. readOnly: !item.editable,
  537. correctFormat: true
  538. };
  539. } else if (item.dataType == dataTypeMap.STRING) { // 文本输入
  540. return {
  541. data: item.path,
  542. readOnly: !item.editable
  543. }
  544. } else { // (未支持的输入方式)暂不支持编辑
  545. return {
  546. data: item.path,
  547. readOnly: !item.editable
  548. }
  549. }
  550. } else { // 动态信息点
  551. // console.log(`%c${item.category}-${item.dataType}`,`color:#c215e1;font-size: 20px;background:#434101`);
  552. return {
  553. data: item.path,
  554. readOnly: !item.editable
  555. }
  556. }
  557. },
  558. filterUnshow: (onlyRead, type, code) => {
  559. let falg = true,
  560. data = fieldData[type]
  561. if (onlyRead) {
  562. data.onlyRead.map(item => {
  563. if (item == code) {
  564. falg = false
  565. }
  566. })
  567. return falg
  568. } else {
  569. data.edit.map(item => {
  570. if (item == code) {
  571. falg = false
  572. }
  573. })
  574. return falg
  575. }
  576. },
  577. filterFirm: (code) => {
  578. let falg = true
  579. firmArr.map(item => {
  580. if (item == code) {
  581. falg = false
  582. }
  583. })
  584. return falg
  585. }
  586. }
  587. export default showTools