
export default {
  execute: function (bill, param) {
    if (bill) {

      bill.runFormulaCheckData(param, function (msg) {
        if (msg.length == 0) {
          let postData = {
            actions: "bill.Basic.save"
          }
          bill.setControlsSate(param["_control_name_"], 'enable', false)
          bill.executeServerAction(postData, function (code, data) {
            bill.setControlsSate(param["_control_name_"], 'enable', true)
            if (code === 200) {
              const id = data.content.billData.id
              GMS.vbus.$emit('change-form-state', { state: 'readOnly', billId: id})
              GMS.vbus.$Message.success("保存成功");
            } else if (code === 201) {
              GMS.vbus.$Message.error(data.message);
            } else if (code === 202) {
              if (data.responseJSON.message && data.responseJSON.message.startsWith("FLOW-")) {
                GMS.vbus.$Message.error({
                  content: data.responseJSON.message,
                  duration: 3
                });
              } else {
                GMS.vbus.$Message.error("保存单据异常请联系管理员");
              }
            }
          })
        } else {
          GMS.vbus.$Modal.warning({
            title: '信息错误',
            content: msg
          });
        }
      })
    }
  }
}