123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- import tools from "@/utils/scan/tools"
- let tagsFun = (instance, td, row, col, prop, value, cellProperties) => {
- if (!!value) {
- let arr = value || [],
- dom = ``;
- arr = arr.sort()
- debugger
- arr.map((item, index) => {
- if (index > 2) {
- } else if (index == 2) {
- dom += '<span>...</span>'
- } else {
- 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>`
- }
- })
- td.innerHTML = dom
- return td;
- }
- return td
- }
- let switchRenderer = (instance, td, row, col, prop, value, cellProperties) => {
- // td.innerHTML = value
- if (value) {
- 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>`
- } else {
- td.innerHTML = `<span class="el-switch__core" style="width: 40px; border-color: #dcdfe6; background-color: #dcdfe6;"></span>`
- }
- return td
- }
- /**
- *
- * @param {表头数组} arr
- * @param {添加的参数} '
- *
- * @returns {对应数组} arr
- */
- export function showTypes(arr, infosKey = '') {
- let data = arr.map(item => {
- if (item.FirstTag == "控制参数" ||
- item.FirstTag == "设定参数" ||
- item.FirstTag == "运行参数") {
- return undefined
- }
- if (item.InfoPointCode == "BIMLocation") {
- return undefined
- }
- if (item.Visible) {
- //固定不显示的code
- // if (!showTools.cantShow(item.InfoPointCode)) {
- // return undefined
- // }
- if (item.InfoPointCode == "edit") {
- return {
- data: "Infos." + item.InfoPointCode,
- renderer: lookQRCode,
- readOnly: true
- }
- }
- //图片类型
- if (
- item.InfoPointCode == "InstallPic" ||
- item.InfoPointCode == "InstallDrawing" ||
- item.InfoPointCode == "Nameplate" ||
- item.InfoPointCode == "Pic" ||
- item.InfoPointCode == "Drawing"
- ) {
- return {
- data: infosKey + item.InfoPointCode,
- // renderer: text.picType,
- readOnly: true
- }
- }
- //文件类型
- if (item.InfoPointCode == "InsuranceFile" ||
- item.InfoPointCode == "Archive" ||
- item.InfoPointCode == "CheckReport") {
- return {
- data: infosKey + item.InfoPointCode,
- // renderer: text.fileType,
- readOnly: true
- }
- }
- if (item.InputMode == "D1") {
- return {
- data: infosKey + item.InfoPointCode,
- renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- // multiple: true,//多选
- data: item.DataSource || ""
- }
- };
- } else if (item.InputMode == "A1" || item.InputMode == "A2") {
- return {
- data: infosKey + item.InfoPointCode,
- type: "numeric",
- numericFormat: {
- pattern: "0,0.00"
- // culture: 'de-DE' // use this for EUR (German),
- // more cultures available on http://numbrojs.com/languages.html
- }
- };
- } else if (item.InputMode == "C5") {
- return {
- data: infosKey + item.InfoPointCode,
- type: "date",
- dateFormat: "YYYY-MM-DD",
- correctFormat: true
- };
- } else if (
- item.InputMode == "B1" ||
- item.InputMode == "L" ||
- item.InputMode == "L1" ||
- item.InputMode == "L2"
- ) {
- return {
- data: infosKey + item.InfoPointCode
- };
- } else if (
- item.InputMode == "X" ||
- item.InputMode == "F2"
- // item.InputMode == "L1" ||
- // item.InputMode == "L2"
- ) {
- // return undefined
- return {
- data: infosKey + item.InfoPointCode,
- readOnly: true
- };
- } else if (item.InputMode == "D2") {
- return {
- data: infosKey + item.InfoPointCode,
- // renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- multiple: true, //多选
- data: item.DataSource || ""
- }
- };
- } else if (item.InputMode == "Own") {
- return {
- data: infosKey + item.InfoPointCode,
- // renderer: text.idType,
- }
- } else if (item.InputMode == "myOwn") {
- return {
- data: infosKey + item.InfoPointCode,
- renderer: tagsFun,
- }
- } else if (item.InputMode == 'select') {
- return {
- data: infosKey + item.InfoPointCode,
- renderer: tools.customDropdownRenderer,
- editor: "chosen",
- chosenOptions: {
- // multiple: true,//多选
- data: item.DataSource || ""
- }
- }
- } else if (item.InputMode == 'switchBtn') {
- return {
- data: infosKey + item.InfoPointCode,
- renderer: switchRenderer,
- readOnly: true
- }
- } else {
- return undefined;
- }
- } else {
- return undefined
- }
- }).filter(item => item);
- return data
- }
- export function changeHeader(arr) {
- let data = arr.map(item => {
- // if (falg) {
- if (item.FirstTag == "控制参数" ||
- item.FirstTag == "设定参数" ||
- item.FirstTag == "运行参数") {
- return undefined
- }
- // }
- if (item.InfoPointCode == "BIMLocation") {
- return undefined
- }
- // if (
- // readArr.indexOf(item.InputMode) > -1
- // ) {
- if (item.Visible) {
- if (!item.Unit) {
- return item.InfoPointName;
- } else {
- return item.InfoPointName + "(" + item.Unit + ")";
- }
- } else {
- return undefined
- }
- // } else {
- // return undefined;
- // }
- }).filter(d => d);
- return data
- }
- let lookQRCode = (instance, td, row, col, prop, value, cellProperties) => {
- td.style.color = "#409EFF";
- td.style.cursor = "pointer";
- td.innerHTML = "编辑"
- return td
- }
|