Auto fill vms form fields for ace projects
当前为
// ==UserScript==
// @name JD VMS ACE
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @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, """)}" />`
).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
);
})