xQuant-JIRA

自动填充解决

目前為 2021-12-17 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         xQuant-JIRA
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  自动填充解决
// @license      AGPL-3.0
// @author       yucheng.meng
// @match        http://jira.xquant.com:8888/browse/P034XPS-*
// @icon         http://jira.xquant.com:8888/s/-7pu1nb/817000/1bcgusu/_/jira-logo-scaled.png
// @require    http://code.jquery.com/jquery-1.11.0.min.js
// @grant        none
// @run-at document-end
// ==/UserScript==

(function() {
    'use strict';
    window.onload=function(){
        // 获取按钮父div
        let div = document.getElementById('opsbar-opsbar-transitions');
        if(div != null){
            // 获取解决按钮信息
            let jjBtn = document.getElementById('action_id_5');
            if(jjBtn != null){
                let href = jjBtn.getAttribute('href');
                // 创建按钮
                let btn = document.createElement('a');
                btn.setAttribute('class','aui-button toolbar-trigger issueaction-workflow-transition');
                btn.setAttribute('href',jjBtn.getAttribute('href'));
                btn.setAttribute('style','color:red');
                btn.innerHTML='<span class="trigger-label">VIP解决问题</span>';
                div.appendChild(btn);
                // 添加点击
                btn.onclick = function (){
                    let timer = setInterval(function(){
                        let dialog = document.getElementById('resolution');
                        if(dialog!=null){
                            clearInterval(timer);
                            fun_a();
                        }
                    },500);
                };

            }
        }
    }
    function fun_a() {
        //解决结果
        let jjjg = document.getElementById('resolution');
        let nodes = jjjg.childNodes;
        for(let i = 0;i<nodes.length;i++){
            let opt =nodes[i];
            if(opt.value){
                if(opt.value == '-1'){
                    opt.removeAttribute('selected');
                }else if(opt.value == '10102'){
                    opt.setAttribute('selected','selected');
                }
            }
        }
        let nowDate = getNowTime();
        // 开发完成日期
        let time1 = document.getElementById('customfield_10216').value = nowDate;
        // 实际开发开始日期 customfield_11708
        document.getElementById('customfield_11708').value = nowDate;
        // 开发完成日期 customfield_11707
        document.getElementById('customfield_11707').value = nowDate;
        // 工作量 customfield_12502
        document.getElementById('customfield_12502').value = '1';
        // 承诺交付 customfield_10207
        document.getElementById('customfield_10207').value = nowDate;
        // 问题实现类型,默认设置公共实现
        document.getElementById('customfield_10102-1').setAttribute('checked','checked');
        // 缺陷类型默认设置为优化
        let qxlxNodes = document.getElementById('customfield_10211').childNodes;
        for(let i = 0;i<qxlxNodes.length;i++){
            let qxl_opt =qxlxNodes[i];
            if(qxl_opt.value){
                if(qxl_opt.value == '13243'){
                    qxl_opt.setAttribute('selected','selected');
                }
            }
        }
        //缺陷原因 默认设置 其他
        let qxyy1_Nodes = document.getElementById('customfield_11519').childNodes;
        for(let i = 0;i<qxyy1_Nodes.length;i++){
            let qxyy1_opt =qxyy1_Nodes[i];
            if(qxyy1_opt.value){
                if(qxyy1_opt.value == '12581'){
                    qxyy1_opt.setAttribute('selected','selected');
                }
            }
        }

        let qxyy2_Nodes = document.getElementById('customfield_11519:1');
        qxyy2_Nodes.innerHTML='<option class="option-group-12581" value="12610" selected>其他</option>';

        // 文档脚本是否提交
        let wdjbtj_Nodes = document.getElementById('customfield_11003').childNodes;
        for(let i = 0;i<wdjbtj_Nodes.length;i++){
            let wdjbtj_opt =wdjbtj_Nodes[i];
            if(wdjbtj_opt.value){
                if(wdjbtj_opt.value == '11832'){
                    wdjbtj_opt.setAttribute('selected','selected');
                }
            }
        }
    }
    // 获取日期
    function getNowTime() {

        let dateTime;
        let yy = new Date().getFullYear();
        let mm = new Date().getMonth() + 1;
        let dd = new Date().getDate();
        let hh = new Date().getHours();
        let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes()
        :
        new Date().getMinutes();
        let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds()
        :
        new Date().getSeconds();
        dateTime = yy + '-' + mm + '-' + dd;
        console.log(dateTime)
        return dateTime

    }

    getNowTime.prototype = {

    };

    fun_a.prototype = {

    };
})();