Skip to content
On this page

来料检测

业务模板

表行编辑规则

js
{
  groupName: "行信息",
  groupNameI18nKey: "i18n_title_lineInformation",
  groupCode: "purchaseQualityCheckItemList",
  groupType: "item",
  sortOrder: "2",
  extend: {
    vxeGridConfig: {
      editConfig: {
        trigger: "click", // 点击触发编辑
        mode: "cell", // 单元格编辑模式
        /**
         * @description: 表行编辑规则
         * @param {Object} pageData 页面所有数据, ref响应对象,注意在使用时须带上.value
         * @param {Object} row 表行数据
         * @param {number} rowIndex 表行索引值
         * @param {Object} column 列配置
         * @param {number} columnIndex 列索引
         * @return {boolean} 返回布尔值, 为 true 时允许编辑
         */
        beforeEditMethod(pageData, { row, rowIndex, column, columnIndex }) {
          debugger;
          // 检验单状态 checkStatus_dictText
          // 数据字典 srmCheckStatus (0: 新建, 1: 检测中, 2: 检测完成)
          // 来源类型 sourceType_dictText
          // 数据字典 checkSourceType (0: 自动创建, 1: 手动创建, 2: 外部系统, 4: 收货凭证)
          if (pageData.value.checkStatus === "0") {
            const props = [
              "checkQuantity", // 检验数量
              "checkType", // 检验方式
              "actualBatch", // 实际批量
              "sampleSize", // 采样大小
            ];
            if (props.includes(column.property)) {
              return true;
            }
          }
          if (pageData.value.checkStatus === "1") {
            const props = [
              "checkDamageQuantity", // 检验破坏数量
              "numberDefectiveProducts", // 不良品数量
              "checkStandards", // 检验标准
              "testResult", // 检验结果
              "decisionConclusion", // 决策结论
              "badReasons", // 不良理由
              "badClassification", // 不良分类
            ];
            if (props.includes(column.property)) {
              return true;
            }
          }
          if (pageData.value.sourceType === "4") {
            const props = [
              "checkQuantity", // 检验数量
              "actualBatch", // 实际批量
              "sampleSize", // 采样大小
            ];
            if (props.includes(column.property)) {
              return true;
            }
          }
          return false;
        },
      },
    },
  },
}

责任人 responsible

json
{
  "groupCode": "baseForm",
  "fieldType": "remoteSelect",
  "fieldLabel": "责任人",
  "fieldName": "responsible",
  "required": "0"
}
js
/**
 * @param {Object} ctx 组件实例
 * @param {String} value 当前所选值
 * @param {Array} data selectModal, remoteSelect 已选行数据 (如有)
 * @param {boolean} _isFill 填充、粘贴操作判断标识
 * @param {Object} row 表行数据 (如有)
 * @param {number} idx 表行索引值 (如有)
 * @param {Object} pageData 页面所有数据
 * @param {Object} layoutConfig 模板配置
 * @param {Object} userInfo 当前登录人信息
 * @param {(groupCode: string, fieldName: string, fn: (item: FormFieldsItem | ColumnItem) => void) => void}
 * customFormatItem 遍历模板分组配置,自定义格式化查询到的字段
 * @param {(groupCode: string, fieldName: string, flag: boolean) => void}
 * setItemRequired 自定义设置字段必填
 * @param {(groupCode: string, fieldName: string, flag: boolean) => void}
 * setItemDisabled 自定义设置字段置灰
 * @param {(groupCode: string, fieldName: string, flag: boolean) => void}
 * setItemRequiredOrDisabled 自定义设置字段必填/置灰
 * @param {() => void} topEmit 用于处理复杂绑定函数需求
 * @param {Constructor} Decimal构造函数, 适用于js小数位数精度计算
 * https://github.com/MikeMcl/decimal.js
 */
function callback(
  ctx,
  {
    value,
    data,
    _isFill,
    row,
    idx,
    pageData,
    layoutConfig,
    userInfo,
    customFormatItem,
    setItemRequired,
    setItemDisabled,
    setItemRequiredOrDisabled,
    topEmit,
    Decimal,
  },
) {
  if (!data || !data.length) {
    return;
  }
  const { realname = "" } = data[0] || {};
  pageData.responsible = realname;
}
js
{
  modalColumns: [
    {
      field: "elsAccount",
      title: "ELS账号",
      with: 150,
    },
    {
      field: "realname",
      title: "姓名",
      with: 150,
    },
    {
      field: "subAccount",
      title: "子账号",
      with: 150,
    },
  ],
  modalUrl: "/account/elsSubAccount/list",
  modalParams: {},
}

对方 ELS 账号 toElsAccount

json
{
  "groupCode": "baseForm",
  "fieldType": "remoteSelect",
  "fieldLabel": "对方ELS账号",
  "fieldName": "toElsAccount",
  "required": "1"
}
js
/**
 * @param {Object} ctx 组件实例
 * @param {String} value 当前所选值
 * @param {Array} data selectModal, remoteSelect 已选行数据 (如有)
 * @param {boolean} _isFill 填充、粘贴操作判断标识
 * @param {Object} row 表行数据 (如有)
 * @param {number} idx 表行索引值 (如有)
 * @param {Object} pageData 页面所有数据
 * @param {Object} layoutConfig 模板配置
 * @param {Object} userInfo 当前登录人信息
 * @param {(groupCode: string, fieldName: string, fn: (item: FormFieldsItem | ColumnItem) => void) => void}
 * customFormatItem 遍历模板分组配置,自定义格式化查询到的字段
 * @param {(groupCode: string, fieldName: string, flag: boolean) => void}
 * setItemRequired 自定义设置字段必填
 * @param {(groupCode: string, fieldName: string, flag: boolean) => void}
 * setItemDisabled 自定义设置字段置灰
 * @param {(groupCode: string, fieldName: string, flag: boolean) => void}
 * setItemRequiredOrDisabled 自定义设置字段必填/置灰
 * @param {() => void} topEmit 用于处理复杂绑定函数需求
 * @param {Constructor} Decimal构造函数, 适用于js小数位数精度计算
 * https://github.com/MikeMcl/decimal.js
 */
function callback(
  ctx,
  {
    value,
    data,
    _isFill,
    row,
    idx,
    pageData,
    layoutConfig,
    userInfo,
    customFormatItem,
    setItemRequired,
    setItemDisabled,
    setItemRequiredOrDisabled,
    topEmit,
    Decimal,
  },
) {
  if (!data || !data.length) {
    return;
  }
  const {
    toElsAccount = "",
    supplierCode = "",
    supplierName = "",
  } = data[0] || {};

  pageData.toElsAccount = toElsAccount;
  pageData.supplierCode = supplierCode;
  pageData.supplierName = supplierName;
}
js
{
  modalColumns: [
    {
      field: "toElsAccount",
      fieldLabelI18nKey: "i18n_title_supplierAccount",
      title: "供应商账号",
      with: 150,
    },
    {
      field: "supplierName",
      fieldLabelI18nKey: "i18n_field_supplierName",
      title: "供应商名称",
      with: 150,
    },
    {
      field: "supplierCode",
      fieldLabelI18nKey: "i18n_field_toCompanyCode",
      title: "供应商编码",
      with: 150,
    },
  ],
  modalUrl: "/supplier/supplierMaster/list",
  params: {},
  isClearCallBindFunction: true,
  handleAfter: function ({ pageData }) {
    pageData.toElsAccount = "";
    pageData.supplierCode = "";
    pageData.supplierName = "";
  },
}