notShow.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. // 不显示的信息点数组
  2. import text from "@/utils/handsontable/mainText"
  3. import tools from "@/utils/scan/tools"
  4. let noShowArr = [
  5. "Brand",
  6. "Specification",
  7. "Manufacturer",
  8. "Supplier",
  9. "SupplierContactor",
  10. "SupplierPhone",
  11. "SupplierEmail",
  12. "SupplierWeb",
  13. "SupplierFax",
  14. "Maintainer",
  15. "MaintainerContactor",
  16. "MaintainerPhone",
  17. "MaintainerEmail",
  18. "MaintainerWeb",
  19. "Principal",
  20. "MaintainerFax",
  21. "Insurer",
  22. "InsurerContactor",
  23. "InsurerPhone",
  24. "InsurerEmail",
  25. "InsurerWeb",
  26. "InsurerFax",
  27. "InsuranceFile",
  28. "EquipID",
  29. "EquipName",
  30. ]
  31. let cantShow = [
  32. "EquipQRCode",
  33. "EquipID",
  34. "EquipName",
  35. "BIMLocation",
  36. "Brand",
  37. "Specification",
  38. "Manufacturer",
  39. "Supplier",
  40. "SupplierContactor",
  41. "SupplierPhone",
  42. "SupplierEmail",
  43. "SupplierWeb",
  44. "SupplierFax",
  45. "Maintainer",
  46. "MaintainerContactor",
  47. "MaintainerPhone",
  48. "MaintainerEmail",
  49. "MaintainerWeb",
  50. "Principal",
  51. "MaintainerFax",
  52. "Insurer",
  53. "InsurerContactor",
  54. "InsurerPhone",
  55. "InsurerEmail",
  56. "InsurerWeb",
  57. "InsurerFax",
  58. "InsuranceFile",
  59. "EquipID",
  60. "EquipName"
  61. ]
  62. let cutArr = [{
  63. name: "品牌型号",
  64. code: "DPManufacturerID",
  65. num: 2,
  66. }, {
  67. name: "供应商信息",
  68. code: "DPSupplierID",
  69. num: 5
  70. }, {
  71. name: "维修商信息",
  72. code: "DPMaintainerID",
  73. num: 19
  74. }, {
  75. name: "保险公司信息",
  76. code: "DPInsurerID",
  77. num: 25
  78. }]
  79. let newData = [{
  80. name: "品牌型号",
  81. code: "DPManufacturerID",
  82. num: 2,
  83. }, {
  84. name: "供应商信息",
  85. code: "DPSupplierID",
  86. num: 8
  87. }, {
  88. name: "维修商信息",
  89. code: "DPMaintainerID",
  90. num: 35
  91. }, {
  92. name: "保险公司信息",
  93. code: "DPInsurerID",
  94. num: 42
  95. }]
  96. const showTools = {
  97. addArr: () => {
  98. return cutArr
  99. },
  100. cantShow: (code) => {
  101. let falg = true
  102. cantShow.map(item => {
  103. if (item == code) {
  104. falg = false
  105. }
  106. })
  107. return falg
  108. },
  109. //几种类型不显示
  110. technologyParam: (item) => {
  111. if (
  112. item.FirstTag == "控制参数" &&
  113. item.FirstTag == "设定参数" &&
  114. item.FirstTag == "运行参数"
  115. ) {
  116. return undefined
  117. }
  118. },
  119. isShow: (code) => {
  120. let falg = true
  121. noShowArr.map(item => {
  122. if (item == code) {
  123. falg = false
  124. }
  125. })
  126. return falg
  127. },
  128. //插入需要的关系
  129. insertionRea: (data) => {
  130. cutArr.map(item => {
  131. data.splice(item.num, 0, item.name)
  132. })
  133. return data
  134. },
  135. insertionRea2: (data) => {
  136. newData.map(item => {
  137. data.splice(item.num, 0, item.name)
  138. })
  139. return data
  140. },
  141. insertionType: (data, callback) => {
  142. cutArr.map(item => {
  143. data.splice(item.num, 0, {
  144. data: "infos." + item.code,
  145. renderer: callback,
  146. readOnly: false
  147. })
  148. })
  149. return data
  150. },
  151. insertionType2: (data, callback) => {
  152. newData.map(item => {
  153. data.splice(item.num, 0, {
  154. data: "infos." + item.code,
  155. renderer: callback,
  156. readOnly: false
  157. })
  158. })
  159. return data
  160. },
  161. arrToArr(arr) {
  162. let first = 0,
  163. scound = 0,
  164. three = 0,
  165. four = 0
  166. arr.find(function(value, index, arr) {
  167. if (
  168. (value.InfoPointName == "品牌" ||
  169. value.InfoPointName == "设备型号" ||
  170. value.InfoPointName == "生产厂家") && !first
  171. ) {
  172. first = index
  173. }
  174. if (
  175. (value.InfoPointName == "供应商单位名称" ||
  176. value.InfoPointName == "供应商联系人" ||
  177. value.InfoPointName == "供应商电子邮件" ||
  178. value.InfoPointName == "供应商网址" ||
  179. value.InfoPointName == "供应商传真" ||
  180. value.InfoPointName == "供应商联系电话") && !scound
  181. ) {
  182. scound = index
  183. }
  184. if (
  185. (value.InfoPointName == "维修商单位名称" ||
  186. value.InfoPointName == "维修商联系人" ||
  187. value.InfoPointName == "维修商联系电话" ||
  188. value.InfoPointName == "维修商电子邮件" ||
  189. value.InfoPointName == "维修商网址" ||
  190. value.InfoPointName == "维修商传真") && !three
  191. ) {
  192. three = index
  193. }
  194. if (
  195. (value.InfoPointName == "保险公司名称" ||
  196. value.InfoPointName == "保险公司联系人" ||
  197. value.InfoPointName == "保险公司联系电话" ||
  198. value.InfoPointName == "保险公司电子邮件" ||
  199. value.InfoPointName == "保险公司网址" ||
  200. value.InfoPointName == "保险公司传真") && !four
  201. ) {
  202. four = index
  203. }
  204. })
  205. let numList = [first, scound, three, four]
  206. numList.reverse().map((item, index) => {
  207. if (!!item) {
  208. if (index == 0) {
  209. arr.splice(item, 0, {
  210. InfoPointName: "保险公司信息",
  211. InfoPointCode: "DPInsurerID",
  212. InputMode: "Own",
  213. Unit: "",
  214. SecondTag: "",
  215. FirstTag: "",
  216. Visible: true,
  217. })
  218. } else if (index == 1) {
  219. arr.splice(item, 0, {
  220. InfoPointName: "维修商信息",
  221. InfoPointCode: "DPMaintainerID",
  222. InputMode: "Own",
  223. Unit: "",
  224. SecondTag: "",
  225. FirstTag: "",
  226. Visible: true,
  227. })
  228. } else if (index == 2) {
  229. arr.splice(item, 0, {
  230. InfoPointName: "供应商信息",
  231. InfoPointCode: "DPSupplierID",
  232. InputMode: "Own",
  233. Unit: "",
  234. SecondTag: "",
  235. FirstTag: "",
  236. Visible: true,
  237. })
  238. } else if (index == 3) {
  239. arr.splice(item, 0, {
  240. InfoPointName: "品牌型号",
  241. InfoPointCode: "DPManufacturerID",
  242. InputMode: "Own",
  243. Unit: "",
  244. SecondTag: "",
  245. FirstTag: "",
  246. Visible: true,
  247. })
  248. }
  249. }
  250. })
  251. return arr
  252. },
  253. changeTypes(arr, onlyRead, isWatch, allMess, falg = false, taizhang = false) {
  254. let data = arr.map(item => {
  255. if (falg) {
  256. if (item.FirstTag == "控制参数" ||
  257. item.FirstTag == "设定参数" ||
  258. item.FirstTag == "运行参数") {
  259. return undefined
  260. }
  261. }
  262. if (item.InfoPointCode == "BIMLocation") {
  263. return undefined
  264. }
  265. if (item.Visible || !allMess) {
  266. //固定不显示的code
  267. if (!showTools.cantShow(item.InfoPointCode) && !onlyRead && !taizhang) {
  268. return undefined
  269. }
  270. if (!showTools.isShow(item.InfoPointCode) && !taizhang && !taizhang) {
  271. if (isWatch && !onlyRead) {
  272. return undefined
  273. }
  274. }
  275. if (item.InfoPointCode == "EquipQRCode") {
  276. return {
  277. data: "Infos." + item.InfoPointCode,
  278. renderer: text.lookQRCode,
  279. readOnly: true
  280. }
  281. }
  282. if (item.InputMode == "D1") {
  283. return {
  284. data: "Infos." + item.InfoPointCode,
  285. renderer: tools.customDropdownRenderer,
  286. editor: "chosen",
  287. chosenOptions: {
  288. // multiple: true,//多选
  289. data: item.DataSource || ""
  290. }
  291. };
  292. } else if (item.InputMode == "A1" || item.InputMode == "A2") {
  293. return {
  294. data: "Infos." + item.InfoPointCode,
  295. type: "numeric",
  296. numericFormat: {
  297. pattern: "0,0.00"
  298. // culture: 'de-DE' // use this for EUR (German),
  299. // more cultures available on http://numbrojs.com/languages.html
  300. }
  301. };
  302. } else if (item.InputMode == "C5") {
  303. return {
  304. data: "Infos." + item.InfoPointCode,
  305. type: "date",
  306. dateFormat: "YYYY-MM-DD",
  307. correctFormat: true
  308. };
  309. } else if (
  310. item.InputMode == "B1" ||
  311. item.InputMode == "L" ||
  312. item.InputMode == "L1" ||
  313. item.InputMode == "L2"
  314. ) {
  315. return {
  316. data: "Infos." + item.InfoPointCode
  317. };
  318. } else if (
  319. item.InputMode == "X"
  320. // item.InputMode == "L1" ||
  321. // item.InputMode == "L2"
  322. ) {
  323. // return undefined
  324. return {
  325. data: "Infos." + item.InfoPointCode,
  326. readOnly: true
  327. };
  328. } else if (item.InputMode == "D2") {
  329. return {
  330. data: "Infos." + item.InfoPointCode,
  331. renderer: tools.customDropdownRenderer,
  332. editor: "chosen",
  333. chosenOptions: {
  334. multiple: true, //多选
  335. data: item.DataSource || ""
  336. }
  337. };
  338. } else if (item.InputMode == "Own" && !onlyRead) {
  339. return {
  340. data: "Infos." + item.InfoPointCode,
  341. renderer: text.idType,
  342. }
  343. } else {
  344. return undefined;
  345. }
  346. } else {
  347. return undefined
  348. }
  349. }).filter(item => item);
  350. return data
  351. },
  352. showTypes(arr, onlyRead, isWatch, allMess, falg = false, typeArr = false) {
  353. let data = arr.map(item => {
  354. if (falg) {
  355. if (item.FirstTag == "控制参数" ||
  356. item.FirstTag == "设定参数" ||
  357. item.FirstTag == "运行参数") {
  358. return undefined
  359. }
  360. }
  361. if (item.InfoPointCode == "BIMLocation") {
  362. return undefined
  363. }
  364. if (!!typeArr && typeArr.indexOf(item.InputMode) > -1) {
  365. return undefined
  366. }
  367. if (item.Visible || !allMess) {
  368. //固定不显示的code
  369. if (!showTools.cantShow(item.InfoPointCode) && !onlyRead) {
  370. return undefined
  371. }
  372. if (!showTools.isShow(item.InfoPointCode)) {
  373. if (isWatch && !onlyRead) {
  374. return undefined
  375. }
  376. }
  377. if (item.InfoPointCode == "EquipQRCode") {
  378. return {
  379. data: "infos." + item.InfoPointCode,
  380. renderer: text.lookQRCode,
  381. readOnly: true
  382. }
  383. }
  384. //图片类型
  385. if (
  386. item.InfoPointCode == "InstallPic" ||
  387. item.InfoPointCode == "InstallDrawing" ||
  388. item.InfoPointCode == "Nameplate" ||
  389. item.InfoPointCode == "Pic" ||
  390. item.InfoPointCode == "Drawing"
  391. ) {
  392. return {
  393. data: "infos." + item.InfoPointCode,
  394. renderer: text.picType,
  395. readOnly: true
  396. }
  397. }
  398. //文件类型
  399. if (item.InfoPointCode == "InsuranceFile" ||
  400. item.InfoPointCode == "Archive" ||
  401. item.InfoPointCode == "CheckReport") {
  402. return {
  403. data: "infos." + item.InfoPointCode,
  404. renderer: text.fileType,
  405. readOnly: true
  406. }
  407. }
  408. if (item.InputMode == "D1") {
  409. return {
  410. data: "infos." + item.InfoPointCode,
  411. renderer: tools.customDropdownRenderer,
  412. editor: "chosen",
  413. chosenOptions: {
  414. // multiple: true,//多选
  415. data: item.DataSource || ""
  416. }
  417. };
  418. } else if (item.InputMode == "A1" || item.InputMode == "A2") {
  419. return {
  420. data: "infos." + item.InfoPointCode,
  421. type: "numeric",
  422. numericFormat: {
  423. pattern: "0,0.00"
  424. // culture: 'de-DE' // use this for EUR (German),
  425. // more cultures available on http://numbrojs.com/languages.html
  426. }
  427. };
  428. } else if (item.InputMode == "C5") {
  429. return {
  430. data: "infos." + item.InfoPointCode,
  431. type: "date",
  432. dateFormat: "YYYY-MM-DD",
  433. correctFormat: true
  434. };
  435. } else if (
  436. item.InputMode == "B1" ||
  437. item.InputMode == "L" ||
  438. item.InputMode == "L1" ||
  439. item.InputMode == "L2"
  440. ) {
  441. return {
  442. data: "infos." + item.InfoPointCode
  443. };
  444. } else if (
  445. item.InputMode == "X" ||
  446. item.InputMode == "F2"
  447. // item.InputMode == "L1" ||
  448. // item.InputMode == "L2"
  449. ) {
  450. // return undefined
  451. return {
  452. data: "infos." + item.InfoPointCode,
  453. readOnly: true
  454. };
  455. } else if (item.InputMode == "D2") {
  456. return {
  457. data: "infos." + item.InfoPointCode,
  458. renderer: tools.customDropdownRenderer,
  459. editor: "chosen",
  460. chosenOptions: {
  461. multiple: true, //多选
  462. data: item.DataSource || ""
  463. }
  464. };
  465. } else if (item.InputMode == "Own" && !onlyRead) {
  466. return {
  467. data: "infos." + item.InfoPointCode,
  468. renderer: text.idType,
  469. }
  470. } else {
  471. return undefined;
  472. }
  473. } else {
  474. return undefined
  475. }
  476. }).filter(item => item);
  477. return data
  478. },
  479. changeHeader(arr, readArr, onlyRead, isWatch, allMess, falg = false, taizhang = false) {
  480. let data = arr.map(item => {
  481. if (falg) {
  482. if (item.FirstTag == "控制参数" ||
  483. item.FirstTag == "设定参数" ||
  484. item.FirstTag == "运行参数") {
  485. return undefined
  486. }
  487. }
  488. if (item.InfoPointCode == "BIMLocation") {
  489. return undefined
  490. }
  491. if (
  492. readArr.indexOf(item.InputMode) > -1
  493. ) {
  494. if (item.Visible || !allMess) {
  495. if (!showTools.cantShow(item.InfoPointCode) && !onlyRead && !taizhang) {
  496. return undefined
  497. }
  498. if (!showTools.isShow(item.InfoPointCode) && !taizhang) {
  499. if (isWatch && !onlyRead) {
  500. return undefined
  501. }
  502. }
  503. if (item.Unit == "") {
  504. return item.InfoPointName;
  505. } else {
  506. return item.InfoPointName + "(" + item.Unit + ")";
  507. }
  508. } else {
  509. return undefined
  510. }
  511. } else {
  512. return undefined;
  513. }
  514. }).filter(d => d);
  515. return data
  516. }
  517. }
  518. export default showTools