JD VMS ACE

Auto fill vms form fields for ace projects

As of 07. 12. 2020. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         JD VMS ACE
// @namespace    com.jd.vms
// @version      1.0.2
// @description  Auto fill vms form fields for ace projects
// @author       tinymins
// @match        http://vms.jd.com/Integration/Apply
// @grant        none
// ==/UserScript==

$('#jacp_card_id').after('<button style="margin: 5px; height: 30px; transform: translateY(2px);">ACE</button>').next().click(() => {
  $("#apply_type").val(4).change();
  const d = new Date();
  d.setTime(d.getTime() + 86400e3 * 30);
  $("#expect_online_date").val(
    [d.getFullYear(), d.getMonth() + 1, d.getDate()]
      .map((a) => (a < 10 ? "0" + a : a))
      .join("-")
  );
  $("#version_server").val("0");
  $("#test_content").val("无");
  $("#module_id").val("73").change();
  $("#self_test").val(0);
  $("#modification_explanation").val("无");
  $("#affect_range").val("无");
  $('[name="degrade_switch_apply"][value="0"]+ins').click();
  $('[name="pressure_test"][value="0"]+ins').click();
  $("#interface_name").val("无");
  $("#test_data").val("无");
  $("#test_address").val("http://beta-ace.jd.com/launch/");
  $("#review_result").val(1).change();
  $("#request-memo").val("无");
  const fetch = (url) => {
    const a = new XMLHttpRequest();
    a.open("GET", url, !1);
    a.withCredentials = !0;
    a.send();
    return a.responseText;
  };
  const fix_erp_tags = async (id, erp) => {
    const data = await $.ajax(
      "http://vms.jd.com/user/get_user_base_info?keyword=" + erp
    ).then((a) => a.info.data.find(({ user_name }) => user_name === erp));
    $(
      `<input id="${id}-hide" type="hidden" value="${JSON.stringify([
        data,
      ]).replace(/"/g, "&quot;")}" />`
    ).insertAfter($("#" + id));
    query_erp("#" + id);
  };
  const card = JSON.parse(
    fetch(
      "http://jagile.jd.com/jacp/api/v1/bizSpaceCard/cardDetail?id=" +
        jacp_card_dom.val()
    )
  );
  const roles = JSON.parse(
    fetch(
      "http://jagile.jd.com/jacp/api/v1/bizConfig/space/kv/" + card.data.spaceId
    )
  ).data.reduce((a, b) => {
    if ((b.name + b.group + "").match(/测试/)) a[b.code] = 1;
    return a;
  }, {});
  fix_erp_tags("code-review-operator", "bihuiting");
  fix_erp_tags("product-operator", card.data.creator.erp);
  fix_erp_tags(
    "test-operator",
    (
      card.data.personHours.find((a) => roles[a.roleCode]) || {
        erp: "leixuepei",
      }
    ).erp
  );
})