| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- /**
- * Created by zhang on 2018/9/3.
- */
- $(document).ready(function () {
- const locked = lockUtil.getLocked();
- lockUtil.lockTools($(document.body), locked);
- try {
- let tem = sortJson(JSON.parse($("#originalInfo").val()), compareInfo);
- $("#template").val(JSON.stringify(tem, null, 4));
- } catch (err) {
- console.log(err);
- }
- $("#format").click(function () {
- try {
- let jsonText = $("#template").val();
- $("#template").val(JSON.stringify(JSON.parse(jsonText), null, 4));
- } catch (err) {
- console.log(err);
- alert("输入的JSON格式有误,请重新输入!");
- }
- });
- $("#save").click(async function () {
- try {
- $.bootstrapLoading.start();
- let libID = $("#libID").val();
- let jsonText = $("#template").val();
- if (jsonText.indexOf("'") != -1) {
- alert(
- "输入的格式不能包含 ' 位于:" +
- jsonText.substr(jsonText.indexOf("'") - 15, 18)
- );
- return;
- }
- await ajaxPost("/itemSetting/saveLib", {
- query: { ID: libID },
- data: { template: JSON.parse(jsonText) },
- });
- $.bootstrapLoading.end();
- } catch (err) {
- $.bootstrapLoading.end();
- console.log(err);
- alert("保存失败,请查看输入数据");
- }
- });
- $("#createNormal").click(async function () {
- let basicTemplate = [
- {
- ID: "1",
- name: "在生产车间边生产边施工",
- base: "人工费",
- coe: 10,
- isCalc: false,
- reductionRate: 100,
- measureRate: 70,
- position: "010001",
- },
- {
- ID: "2",
- name: "在有害身体健康的场所内施工",
- base: "人工费",
- coe: 10,
- isCalc: false,
- reductionRate: 100,
- measureRate: 70,
- position: "010001",
- },
- {
- ID: "3",
- name: "在洞内、地下室内、库内或暗室内进行施工",
- base: "人工费",
- coe: 40,
- isCalc: false,
- reductionRate: 100,
- measureRate: 70,
- position: "010001",
- },
- {
- ID: "4",
- name: "在洞内、地下室内、库内或暗室内进行施工(模板拆除)",
- base: "人工费",
- coe: 10,
- isCalc: false,
- reductionRate: 100,
- measureRate: 70,
- position: "010001",
- },
- ];
- try {
- let jsonText = JSON.stringify(basicTemplate);
- $("#template").val(JSON.stringify(JSON.parse(jsonText), null, 4));
- } catch (err) {
- console.log(err);
- }
- });
- });
- function compareInfo(a, b) {
- let mapping = {
- ID: 1,
- name: 2,
- };
- let aV = mapping[a] ? mapping[a] : 0,
- bV = mapping[b] ? mapping[b] : 0;
- return aV - bV;
- }
|