notShow.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  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. console.log(item.path);
  336. if (
  337. // item.code == "EquipQRCode" ||
  338. // item.code == "RoomQRCode"
  339. item.code == "defaultQRCode"
  340. ) {
  341. return {
  342. data: item.path,
  343. renderer: text.lookQRCode,
  344. readOnly: onlyRead
  345. }
  346. }
  347. //图片类型
  348. if (
  349. item.code == "installPic" ||
  350. item.code == "nameplate" ||
  351. item.code == "pic"
  352. ) {
  353. return {
  354. data: item.path,
  355. renderer: text.picType,
  356. readOnly: onlyRead
  357. }
  358. }
  359. //文件类型
  360. if (item.code == "insuranceFile" ||
  361. item.code == "archive" ||
  362. item.code == "checkReport" ||
  363. item.code == "maintainManual" ||
  364. item.code == "approachingAcceptance" ||
  365. item.code == "acceptanceReport" ||
  366. item.code == "operationManual" ||
  367. item.code == "originalCertificate" ||
  368. item.code == "testReport" ||
  369. item.code == "productCertification" ||
  370. item.code == "installInstruction" ||
  371. item.code == "supplierContract" ||
  372. item.code == "drawing" ||
  373. item.code == "installDrawing"
  374. ) {
  375. return {
  376. data: item.path,
  377. renderer: text.fileType,
  378. readOnly: onlyRead
  379. }
  380. }
  381. if (item.category == 'STATIC') {
  382. if (item.dataType == dataTypeMap.ENUM || item.dataType == dataTypeMap.BOOLEAN) { //单选输入
  383. return {
  384. data: item.path,
  385. renderer: tools.customDropdownRenderer,
  386. editor: "chosen",
  387. readOnly: onlyRead,
  388. chosenOptions: {
  389. data: item.dataSource ? tools.formatDataSource(item.dataSource) : ""
  390. }
  391. };
  392. } else if (item.dataType == dataTypeMap.DOUBLE || item.dataType == dataTypeMap.INTEGER) { // 数字输入
  393. return {
  394. data: item.path,
  395. renderer: tools.customDropdownRenderer,
  396. editor: "chosen",
  397. readOnly: onlyRead,
  398. chosenOptions: {
  399. multiple: true, //多选
  400. data: item.dataSource ? tools.formatDataSource(item.dataSource) : ""
  401. }
  402. };
  403. } else if (item.dataType == dataTypeMap.DOUBLE || item.dataType == dataTypeMap.INTEGER) { // 数字输入
  404. return {
  405. data: item.path,
  406. type: "numeric",
  407. readOnly: onlyRead,
  408. numericFormat: {
  409. pattern: "0,0.00"
  410. }
  411. };
  412. } else if (item.dataType == dataTypeMap.DATETIME) { // 日期输入
  413. return {
  414. data: item.path,
  415. type: "date",
  416. dateFormat: "YYYYMMDDHHmmss",
  417. readOnly: onlyRead,
  418. correctFormat: true
  419. };
  420. } else if (item.dataType == dataTypeMap.STRING) { // 文本输入
  421. return {
  422. data: item.path,
  423. readOnly: onlyRead
  424. }
  425. } else { //(未支持的输入方式)暂不支持编辑
  426. return {
  427. data: item.path,
  428. readOnly: onlyRead
  429. }
  430. }
  431. } else {// 动态信息点
  432. console.log(`%c${item.category}-${item.dataType}`,`color:#c215e1;font-size: 20px;background:#434101`);
  433. return {
  434. data: item.path,
  435. readOnly: !item.editable
  436. }
  437. }
  438. },
  439. inputModeFilter(item, onlyRead) {
  440. if (
  441. // item.code == "EquipQRCode" ||
  442. // item.code == "RoomQRCode"
  443. item.code == "defaultQRCode"
  444. ) {
  445. return {
  446. data: item.path,
  447. renderer: text.lookQRCode,
  448. readOnly: !item.editable
  449. }
  450. }
  451. //图片类型
  452. if (
  453. item.code == "installPic" ||
  454. item.code == "nameplate" ||
  455. item.code == "pic"
  456. ) {
  457. return {
  458. data: item.path,
  459. renderer: text.picType,
  460. readOnly: !item.editable
  461. }
  462. }
  463. //文件类型
  464. if (item.code == "insuranceFile" ||
  465. item.code == "archive" ||
  466. item.code == "checkReport" ||
  467. item.code == "maintainManual" ||
  468. item.code == "approachingAcceptance" ||
  469. item.code == "acceptanceReport" ||
  470. item.code == "operationManual" ||
  471. item.code == "originalCertificate" ||
  472. item.code == "testReport" ||
  473. item.code == "productCertification" ||
  474. item.code == "installInstruction" ||
  475. item.code == "supplierContract" ||
  476. item.code == "drawing" ||
  477. item.code == "installDrawing"
  478. ) {
  479. return {
  480. data: item.path,
  481. renderer: text.fileType,
  482. readOnly: !item.editable
  483. }
  484. }
  485. //四大厂商
  486. if (
  487. item.code == "dpSupplierId" ||
  488. item.code == "dpMaintainerId" ||
  489. item.code == "dpInsurerId" ||
  490. item.code == "dpManufacturerId"
  491. ) {
  492. return {
  493. data: item.path,
  494. renderer: text.idType,
  495. readOnly: !item.editable
  496. }
  497. }
  498. if (!item.category) {
  499. console.log('新版字典无输入类型', item)
  500. }
  501. if (item.category == 'STATIC') {
  502. if (item.dataType == dataTypeMap.ENUM || item.dataType == dataTypeMap.BOOLEAN) { //单选输入
  503. return {
  504. data: item.path,
  505. renderer: tools.customDropdownRenderer,
  506. editor: "chosen",
  507. readOnly: !item.editable,
  508. chosenOptions: {
  509. data: item.dataSource ? tools.formatDataSource(item.dataSource) : ""
  510. }
  511. };
  512. } else if (item.dataType == dataTypeMap.MENUM) { //多选输入
  513. return {
  514. data: item.path,
  515. renderer: tools.customDropdownRenderer,
  516. editor: "chosen",
  517. readOnly: !item.editable,
  518. chosenOptions: {
  519. multiple: true, //多选
  520. data: item.dataSource ? tools.formatDataSource(item.dataSource) : ""
  521. }
  522. };
  523. } else if (item.dataType == dataTypeMap.DOUBLE || item.dataType == dataTypeMap.INTEGER) { // 数字输入
  524. return {
  525. data: item.path,
  526. type: "numeric",
  527. readOnly: !item.editable,
  528. numericFormat: {
  529. pattern: "0,0.00"
  530. }
  531. };
  532. } else if (item.dataType == dataTypeMap.DATETIME) { // 日期输入
  533. return {
  534. data: item.path,
  535. type: "date",
  536. dateFormat: item.formater || "YYYYMMDDHHmmss",
  537. readOnly: !item.editable,
  538. correctFormat: true
  539. };
  540. } else if (item.dataType == dataTypeMap.STRING) { // 文本输入
  541. return {
  542. data: item.path,
  543. readOnly: !item.editable
  544. }
  545. } else { // (未支持的输入方式)暂不支持编辑
  546. return {
  547. data: item.path,
  548. readOnly: !item.editable
  549. }
  550. }
  551. } else { // 动态信息点
  552. console.log(`%c${item.category}-${item.dataType}`,`color:#c215e1;font-size: 20px;background:#434101`);
  553. return {
  554. data: item.path,
  555. readOnly: !item.editable
  556. }
  557. }
  558. },
  559. filterUnshow: (onlyRead, type, code) => {
  560. let falg = true,
  561. data = fieldData[type]
  562. if (onlyRead) {
  563. data.onlyRead.map(item => {
  564. if (item == code) {
  565. falg = false
  566. }
  567. })
  568. return falg
  569. } else {
  570. data.edit.map(item => {
  571. if (item == code) {
  572. falg = false
  573. }
  574. })
  575. return falg
  576. }
  577. },
  578. filterFirm: (code) => {
  579. let falg = true
  580. firmArr.map(item => {
  581. if (item == code) {
  582. falg = false
  583. }
  584. })
  585. return falg
  586. }
  587. }
  588. export default showTools