delType.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import tools from "@/utils/scan/tools"
  2. let tagsFun = (instance, td, row, col, prop, value, cellProperties) => {
  3. if (!!value) {
  4. let arr = value || [],
  5. dom = ``;
  6. arr.map((item, index) => {
  7. if (index > 2) {
  8. } else if (index == 2) {
  9. dom += '<span>...</span>'
  10. } else {
  11. dom += `<span style="display: inline-block;line-height:20px;height: 20px;box-sizing:border-box;padding: 0px 10px;background: #FFF5E4;border: 1px solid #F5A623;border-radius: 100px;font-size: 12px;color: #F5A623;text-align: center;margin: 4px 4px 0 0;">${item}</span>`
  12. }
  13. })
  14. td.innerHTML = dom
  15. return td;
  16. }
  17. return td
  18. }
  19. let switchRenderer = (instance, td, row, col, prop, value, cellProperties) => {
  20. // td.innerHTML = value
  21. if (value) {
  22. td.innerHTML = `<div role="switch" class="el-switch is-checked" aria-checked="true"><input type="checkbox" name="" true-value="true" class="el-switch__input"><!----><span class="el-switch__core" style="width: 40px; border-color: rgb(19, 206, 102); background-color: rgb(19, 206, 102);"></span><!----></div>`
  23. } else {
  24. td.innerHTML = `<span class="el-switch__core" style="width: 40px; border-color: #dcdfe6; background-color: #dcdfe6;"></span>`
  25. }
  26. return td
  27. }
  28. /**
  29. *
  30. * @param {表头数组} arr
  31. * @param {添加的参数} '
  32. *
  33. * @returns {对应数组} arr
  34. */
  35. export function showTypes(arr, infosKey = '') {
  36. let data = arr.map(item => {
  37. if (item.FirstTag == "控制参数" ||
  38. item.FirstTag == "设定参数" ||
  39. item.FirstTag == "运行参数") {
  40. return undefined
  41. }
  42. if (item.InfoPointCode == "BIMLocation") {
  43. return undefined
  44. }
  45. if (item.Visible) {
  46. //固定不显示的code
  47. // if (!showTools.cantShow(item.InfoPointCode)) {
  48. // return undefined
  49. // }
  50. if (item.InfoPointCode == "edit") {
  51. return {
  52. data: "Infos." + item.InfoPointCode,
  53. renderer: lookQRCode,
  54. readOnly: true
  55. }
  56. }
  57. //图片类型
  58. if (
  59. item.InfoPointCode == "InstallPic" ||
  60. item.InfoPointCode == "InstallDrawing" ||
  61. item.InfoPointCode == "Nameplate" ||
  62. item.InfoPointCode == "Pic" ||
  63. item.InfoPointCode == "Drawing"
  64. ) {
  65. return {
  66. data: infosKey + item.InfoPointCode,
  67. // renderer: text.picType,
  68. readOnly: true
  69. }
  70. }
  71. //文件类型
  72. if (item.InfoPointCode == "InsuranceFile" ||
  73. item.InfoPointCode == "Archive" ||
  74. item.InfoPointCode == "CheckReport") {
  75. return {
  76. data: infosKey + item.InfoPointCode,
  77. // renderer: text.fileType,
  78. readOnly: true
  79. }
  80. }
  81. if (item.InputMode == "D1") {
  82. return {
  83. data: infosKey + item.InfoPointCode,
  84. renderer: tools.customDropdownRenderer,
  85. editor: "chosen",
  86. chosenOptions: {
  87. // multiple: true,//多选
  88. data: item.DataSource || ""
  89. }
  90. };
  91. } else if (item.InputMode == "A1" || item.InputMode == "A2") {
  92. return {
  93. data: infosKey + item.InfoPointCode,
  94. type: "numeric",
  95. numericFormat: {
  96. pattern: "0,0.00"
  97. // culture: 'de-DE' // use this for EUR (German),
  98. // more cultures available on http://numbrojs.com/languages.html
  99. }
  100. };
  101. } else if (item.InputMode == "C5") {
  102. return {
  103. data: infosKey + item.InfoPointCode,
  104. type: "date",
  105. dateFormat: "YYYY-MM-DD",
  106. correctFormat: true
  107. };
  108. } else if (
  109. item.InputMode == "B1" ||
  110. item.InputMode == "L" ||
  111. item.InputMode == "L1" ||
  112. item.InputMode == "L2"
  113. ) {
  114. return {
  115. data: infosKey + item.InfoPointCode
  116. };
  117. } else if (
  118. item.InputMode == "X" ||
  119. item.InputMode == "F2"
  120. // item.InputMode == "L1" ||
  121. // item.InputMode == "L2"
  122. ) {
  123. // return undefined
  124. return {
  125. data: infosKey + item.InfoPointCode,
  126. readOnly: true
  127. };
  128. } else if (item.InputMode == "D2") {
  129. return {
  130. data: infosKey + item.InfoPointCode,
  131. // renderer: tools.customDropdownRenderer,
  132. editor: "chosen",
  133. chosenOptions: {
  134. multiple: true, //多选
  135. data: item.DataSource || ""
  136. }
  137. };
  138. } else if (item.InputMode == "Own") {
  139. return {
  140. data: infosKey + item.InfoPointCode,
  141. // renderer: text.idType,
  142. }
  143. } else if (item.InputMode == "myOwn") {
  144. return {
  145. data: infosKey + item.InfoPointCode,
  146. renderer: tagsFun,
  147. }
  148. } else if (item.InputMode == 'select') {
  149. return {
  150. data: infosKey + item.InfoPointCode,
  151. renderer: tools.customDropdownRenderer,
  152. editor: "chosen",
  153. chosenOptions: {
  154. // multiple: true,//多选
  155. data: item.DataSource || ""
  156. }
  157. }
  158. } else if (item.InputMode == 'switchBtn') {
  159. return {
  160. data: infosKey + item.InfoPointCode,
  161. renderer: switchRenderer,
  162. readOnly: true
  163. }
  164. } else {
  165. return undefined;
  166. }
  167. } else {
  168. return undefined
  169. }
  170. }).filter(item => item);
  171. return data
  172. }
  173. export function changeHeader(arr) {
  174. let data = arr.map(item => {
  175. // if (falg) {
  176. if (item.FirstTag == "控制参数" ||
  177. item.FirstTag == "设定参数" ||
  178. item.FirstTag == "运行参数") {
  179. return undefined
  180. }
  181. // }
  182. if (item.InfoPointCode == "BIMLocation") {
  183. return undefined
  184. }
  185. // if (
  186. // readArr.indexOf(item.InputMode) > -1
  187. // ) {
  188. if (item.Visible) {
  189. if (!item.Unit) {
  190. return item.InfoPointName;
  191. } else {
  192. return item.InfoPointName + "(" + item.Unit + ")";
  193. }
  194. } else {
  195. return undefined
  196. }
  197. // } else {
  198. // return undefined;
  199. // }
  200. }).filter(d => d);
  201. return data
  202. }
  203. let lookQRCode = (instance, td, row, col, prop, value, cellProperties) => {
  204. td.style.color = "#409EFF";
  205. td.style.cursor = "pointer";
  206. td.innerHTML = "编辑"
  207. return td
  208. }