index.html 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  5. <meta http-equiv="Pragma" content="no-cache" />
  6. <meta http-equiv="Expires" content="0" />
  7. <meta charset="utf-8">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  9. <link rel="shortcut icon" href="/img/logo.png" />
  10. <link rel="bookmark" href="/img/logo.png" />
  11. <link rel="stylesheet" href="/plugins/bootstrap-4.3.1/css/bootstrap.min.css">
  12. <link rel="stylesheet" href="/plugins/font-awesome-4.7.0/css/font-awesome.min.css">
  13. <link href="/Plugins/bootstrap-select/css/bootstrap-select.min.css" rel="stylesheet" />
  14. <link rel="stylesheet" href="../common/StyleSheet.css" />
  15. <script src="/Plugins/jquery-3.4.1/jquery-3.4.1.min.js"></script>
  16. <script src="/Plugins/virtualkeyboard/xvirtualkeyboard.js"></script>
  17. <style type="text/css">
  18. .nav-link {
  19. padding: .4rem 0.6rem;
  20. }
  21. tr, th, td {
  22. height: 22px !important;
  23. padding: 4px !important;
  24. }
  25. </style>
  26. <title>东科软件</title>
  27. </head>
  28. <body class="bg-light">
  29. <!--导航菜单-->
  30. <script src="../common/navbar.js"></script>
  31. <!--质量登记表单-->
  32. <div class="container-fluid">
  33. <div class="row pt-2">
  34. <div class="col-lg-6 col-sm-12 pt-0 pb-2 pr-lg-1">
  35. <!--产品分级-->
  36. <div class="rounded bg-white shadow-sm pl-4 pt-3 pr-4 pl-4 pb-2">
  37. <form class="pt-0">
  38. <div class="form-row">
  39. <div class="form-group col-4 mb-1">
  40. <label for="生产工号">生产工号</label>
  41. <input readonly type="text" class="form-control border-secondary" id="生产工号" placeholder="请输入" required>
  42. </div>
  43. <div class="form-group col-4 mb-1">
  44. <label for="产品条码">产品条码</label>
  45. <input value="10009342283" onkeydown="if (event.keyCode == 13) loadProduct();" type="text" class="form-control" id="产品条码" placeholder="请输入" required>
  46. <div id="softkeyboard"></div>
  47. </div>
  48. <div class="form-group col-4 align-self-end mb-1">
  49. <button onclick="loadProduct()" id="产品查询" type="button" class="btn btn-info btn-block">产品查询</button>
  50. </div>
  51. </div>
  52. <div class="form-row">
  53. <div class="form-group col-4 mb-1">
  54. <input type="text" class="form-control border-secondary" id="产品编码" placeholder="查询" readonly>
  55. </div>
  56. <div class="form-group col-4 mb-1">
  57. <input type="text" class="form-control border-secondary" id="产品商标" placeholder="查询" readonly>
  58. </div>
  59. <div class="form-group col-4 mb-1">
  60. <input type="text" class="form-control border-secondary" id="产品釉料" placeholder="查询" readonly>
  61. </div>
  62. </div>
  63. <div class="form-row">
  64. <div class="form-group col-4">
  65. <input type="text" class="form-control border-secondary" id="漏气" placeholder="查询" readonly>
  66. </div>
  67. <div class="form-group col-4">
  68. <input type="text" class="form-control border-secondary" id="内漏" placeholder="查询" readonly>
  69. </div>
  70. <div class="form-group col-4">
  71. <input type="text" class="form-control border-secondary" id="通球" placeholder="查询" readonly>
  72. </div>
  73. </div>
  74. <div class="form-row">
  75. <div class="form-group col-4">
  76. <!--产品分级变量-->
  77. <div style="display:none;">
  78. <label for="产品分级">产品分级</label>
  79. <select id="产品分级" onchange="goodsLevel_OnChange()" class="custom-select" required disabled>
  80. <option value="">请选择...</option>
  81. </select>
  82. </div>
  83. <!--产品分级按钮-->
  84. <div id="产品分级按钮模板" style="display:none;">
  85. <label class="btn btn-info btn-lg active" onclick="goodsLevelSelect('{id}')">
  86. <input type="radio" name="产品分级按钮项" id="产品分级{text}" value="{text}"> {text}
  87. </label>
  88. </div>
  89. <div id="产品分级按钮" class="btn-group btn-group-toggle pt-4" data-toggle="buttons">
  90. <label class="btn btn-info btn-lg" onclick="goodsLevelSelect('0')">
  91. <input type="radio" name="产品分级按钮项" id="产品分级正品" value="正品"> 正品
  92. </label>
  93. <label class="btn btn-info btn-lg" onclick="goodsLevelSelect('0')">
  94. <input type="radio" name="产品分级按钮项" id="产品分级副品" value="副品"> 副品
  95. </label>
  96. <label class="btn btn-info btn-lg" onclick="goodsLevelSelect('0')">
  97. <input type="radio" name="产品分级按钮项" id="产品分级重烧" value="重烧"> 重烧
  98. </label>
  99. <label class="btn btn-info btn-lg" onclick="goodsLevelSelect('0')">
  100. <input type="radio" name="产品分级按钮项" id="产品分级次品" value="次品"> 次品
  101. </label>
  102. <label class="btn btn-info btn-lg" onclick="goodsLevelSelect('0')">
  103. <input type="radio" name="产品分级按钮项" id="产品分级次品" value="冷补"> 冷补
  104. </label>
  105. </div>
  106. </div>
  107. <div class="form-group col-4">
  108. <label for="返工工序">返工工序</label>
  109. <select id="返工工序" class="custom-select" required disabled>
  110. <option value="">请选择...</option>
  111. </select>
  112. </div>
  113. <div class="form-group col-1">
  114. <label for="重烧">重烧</label>
  115. <input type="text" class="form-control border-secondary" id="重烧" placeholder="查询" readonly>
  116. </div>
  117. <div class="form-group col-1">
  118. <label for="干补">干补</label>
  119. <input type="text" class="form-control border-secondary" id="干补" placeholder="查询" readonly>
  120. </div>
  121. <div class="form-group col-1">
  122. <label for="冷补">冷补</label>
  123. <input type="text" class="form-control border-secondary" id="冷补" placeholder="查询" readonly>
  124. </div>
  125. </div>
  126. <div class="form-row">
  127. <div class="form-group col-12 align-self-end">
  128. <button onclick="productSave()" id="产品分级保存按钮" type="button" class="btn btn-danger btn-block" disabled>保存产品分级</button>
  129. </div>
  130. </div>
  131. </form>
  132. </div>
  133. </div>
  134. <div class="col-lg-6 col-sm-12 pt-0 pb-2 pl-lg-1">
  135. <!--产品缺陷登记-->
  136. <div class="rounded bg-white shadow-sm pl-4 pt-3 pr-4 pl-4 pb-2">
  137. <form class="pt-0">
  138. <div class="form-row">
  139. <div class="form-group col-4">
  140. <label for="缺陷名称">缺陷名称</label>
  141. <div class="input-group">
  142. <input type="text" class="form-control border-secondary" id="缺陷名称" placeholder="查询" readonly>
  143. <div class="input-group-append">
  144. <button class="btn btn-info" onclick="productDefect_OnClick(procedureId)" type="button" id="选择缺陷按钮" disabled>选择</button>
  145. </div>
  146. </div>
  147. </div>
  148. <div class="form-group col-4">
  149. <label for="缺陷位置">缺陷位置</label>
  150. <div class="input-group">
  151. <input type="text" class="form-control border-secondary" id="缺陷位置" placeholder="查询" readonly>
  152. <div class="input-group-append">
  153. <button class="btn btn-info" onclick="productDefectPosition_OnClick(procedureId)" type="button" id="选择位置按钮" disabled>选择</button>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="form-group col-4">
  158. <label for="特殊缺陷">特殊缺陷</label>
  159. <select id="特殊缺陷" class="custom-select" required disabled>
  160. <option value="" selected>请选择...</option>
  161. <option value="1">1</option>
  162. <option value="0">0</option>
  163. </select>
  164. </div>
  165. </div>
  166. <div class="form-row">
  167. <div class="form-group col-4">
  168. <label for="责任工序">责任工序</label>
  169. <select onchange="defectProcedure_OnChange()" id="责任工序" class="custom-select" required disabled>
  170. <option value="">请选择...</option>
  171. </select>
  172. </div>
  173. <div class="form-group col-4">
  174. <label for="责任工号">责任工号</label>
  175. <div class="input-group">
  176. <input type="text" onkeyup="this.value=this.value.toUpperCase()" onkeydown="if (event.keyCode == 13) loadDefectByUserCode(procedureId);" class="form-control border-secondary" id="责任工号" placeholder="请输入..." disabled>
  177. <div class="input-group-append">
  178. <button class="btn btn-info" onclick="loadDefectByUserCode(procedureId)" type="button" id="责任工号按钮" disabled>查询</button>
  179. </div>
  180. </div>
  181. </div>
  182. <div class="form-group col-4">
  183. <label for="责任工种">责任工种</label>
  184. <select id="责任工种" class="custom-select" onchange="defectJobs_OnChange()" required disabled>
  185. <option value="">请选择...</option>
  186. </select>
  187. </div>
  188. </div>
  189. <div class="form-row">
  190. <div class="form-group col-4">
  191. <label for="责任人">责任人</label>
  192. <select id="责任人" class="form-control selectpicker" title="请选择..." multiple required disabled>
  193. <option value="">请选择...</option>
  194. </select>
  195. </div>
  196. <div class="form-group col-4">
  197. <label for="缺陷扣罚">缺陷扣罚</label>
  198. <select id="缺陷扣罚" class="custom-select" required disabled>
  199. <option value="">请选择...</option>
  200. </select>
  201. </div>
  202. <div class="form-group col-4">
  203. <label for="扣除数">扣除数</label>
  204. <select id="扣除数" class="custom-select" required disabled>
  205. <option value="">请选择...</option>
  206. </select>
  207. </div>
  208. </div>
  209. <div class="form-row">
  210. <div class="form-group col-12 align-self-end">
  211. <button onclick="productDefectSaveOne()" id="产品缺陷保存按钮" type="button" class="btn btn-secondary btn-block" disabled>保存产品缺陷</button>
  212. </div>
  213. <!--<div class="form-group col-6 align-self-end">
  214. <button onclick="productDefectSaveMore()" id="产品缺陷保存按钮多次" type="button" class="btn btn-warning btn-block" disabled>保存缺陷(多次)</button>
  215. </div>-->
  216. </div>
  217. <div class="form-row">
  218. </div>
  219. </form>
  220. </div>
  221. </div>
  222. </div>
  223. <div class="row">
  224. <div class="col-lg-12 pt-0 pb-0">
  225. <!--产品缺陷记录登记-->
  226. <div class="rounded bg-white shadow-sm pl-4 pr-4 pt-4 pb-2">
  227. <table class="table table-bordered">
  228. <thead>
  229. <tr>
  230. <th>缺陷名称</th>
  231. <th>缺陷位置</th>
  232. <th>责任工序</th>
  233. <th>工号</th>
  234. <th>工种</th>
  235. <th>责任人</th>
  236. <th>扣罚</th>
  237. <th>扣除</th>
  238. <th>特殊</th>
  239. <th>&nbsp;</th>
  240. </tr>
  241. </thead>
  242. <tbody id="产品缺陷列表">
  243. </tbody>
  244. </table>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. <!--缺陷列表模板-->
  250. <div class="d-none">
  251. <table>
  252. <tbody id="缺陷列表模板">
  253. <tr id="{缺陷标识}">
  254. <td>{缺陷编码}{缺陷名称}</td>
  255. <td>{位置编码}{缺陷位置}</td>
  256. <td>{责任工序}</td>
  257. <td>{责任工号}</td>
  258. <td>{责任工种}</td>
  259. <td>{责任人}</td>
  260. <td>{缺陷扣罚}</td>
  261. <td>{扣除数}</td>
  262. <td>{特殊缺陷}</td>
  263. <td><button delbutton="true" onclick="productDefectDelete('{缺陷标识}')" class="btn btn-sm btn-block btn-danger" type="button">删除</button></td>
  264. </tr>
  265. </tbody>
  266. </table>
  267. </div>
  268. <!--对话框-->
  269. <script src="../common/dialog.js"></script>
  270. <!--产品缺陷对话框-->
  271. <script src="../common/dialogDefect.js"></script>
  272. <!--产品缺陷位置对话框-->
  273. <script src="../common/dialogDefectPosition.js"></script>
  274. <!--版权信息-->
  275. <script src="../common/footer.js"></script>
  276. <script src="/Plugins/bootstrap-4.3.1/js/bootstrap.bundle.min.js"></script>
  277. <script src="/Plugins/bootstrap-select/js/bootstrap-select.min.js"></script>
  278. <script src="/Plugins/sweetalert/sweetalert.min.js"></script>
  279. <script src="/Plugins/xrequest/xrequest.min.js"></script>
  280. <script src="../Common/xuwell.js"></script>
  281. <script>
  282. //xuwei 2020-04-21
  283. //计件标记变量 1新建 2改判 3冷补后
  284. var checkFlag = '1';
  285. //是否打印条码
  286. var printBarcode = false;
  287. //成检工序ID
  288. var procedureId = request('id');
  289. //接口数据源定义
  290. var completeProcedure;
  291. var jsonUser;
  292. var jsonGoodsLevel;
  293. var jsonProcedure;
  294. var jsonStaff;
  295. var defectUserId;
  296. var jsonProductData;
  297. var procedureReFire = [];
  298. var procedureLengbu = [];
  299. var goodsModelForCheck = ""; //物料编码区分大件小件 20230223
  300. //操作方式 insert update
  301. var action = "";
  302. //用于提交的缺陷数据
  303. var productionDefects = [];
  304. //用于显示的缺陷数据
  305. var defectJson = [];
  306. var defectCount = 0;
  307. var userId = "";
  308. $(document).ready(function () {
  309. //读取是否打印条码
  310. //$.get('print/getprint.ashx', function (d) {
  311. // var p = JSON.parse(d);
  312. // printBarcode = p['success']
  313. //});
  314. //加载数据
  315. loadData();
  316. //加载产品返工工序
  317. $.get('api/GetProductCheckReworkProcedure_WCF.ashx?id=' + procedureId, function (data) {
  318. var returnProcedure = JSON.parse(data);
  319. //20230223 qinqi 多条重烧返工工序数据源
  320. for (var i = 0; i < returnProcedure.rows.length; i++) {
  321. if (returnProcedure.rows[i]["REWORKPROCEDURENAME"].indexOf("重烧") >= 0) {
  322. procedureReFire.push(returnProcedure.rows[i]);
  323. }
  324. else if (returnProcedure.rows[i]["REWORKPROCEDURENAME"].indexOf("冷补") >= 0) {
  325. procedureLengbu.push(returnProcedure.rows[i]);
  326. }
  327. }
  328. //procedureReFire.push(returnProcedure.rows[0]);
  329. //procedureLengbu.push(returnProcedure.rows[1]);
  330. });
  331. });
  332. //产品分级按钮事件
  333. function goodsLevelSelect(value) {
  334. $("#产品分级").val(value);
  335. goodsLevel_OnChange();
  336. }
  337. function keyBoard() {
  338. //加载软键盘
  339. $('#产品条码').keyboard({ usePreview: false, autoAccept: true });
  340. //$('#备注').keyboard({ usePreview: false, autoAccept: true });
  341. $('#责任工号').keyboard({ usePreview: false, autoAccept: true });
  342. swal({
  343. title: '产品分级',
  344. text: '软键盘已加载!',
  345. icon: 'success',
  346. button: '确定'
  347. });
  348. }
  349. //加载 生产工号
  350. function loadData() {
  351. //检查登录状态
  352. $.get('api/LogInCheck_WCF.ashx', function (data) {
  353. var json = JSON.parse(data);
  354. if (json["success"] == true) {
  355. //登录状态
  356. $('#生产工号').val(json["rows"]["userCode"]);
  357. //保存登录数据源
  358. jsonUser = json["rows"];
  359. }
  360. else {
  361. swal({
  362. title: '登录异常!',
  363. text: '请您先登录系统!',
  364. icon: 'error',
  365. button: '确定'
  366. }).then(function () {
  367. window.location = '/main/login/login.html';
  368. });
  369. }
  370. });
  371. ClearProductDefectList();
  372. }
  373. //清空 产品缺陷列表 位置
  374. function ClearProductDefectList() {
  375. $('#产品缺陷列表').html('<tr><td colspan="9" style="text-align:center">暂无产品缺陷数据。<td></tr>');
  376. defectJson = [];
  377. productionDefects = [];
  378. defectCount = 0;
  379. }
  380. //输入条码 加载 产品信息
  381. function loadProduct() {
  382. swal({
  383. title: '产品分级',
  384. text: '正在查询数据,请稍候。。。',
  385. icon: 'info',
  386. button: false,
  387. closeOnClickOutside: false
  388. });
  389. //2020-07-02 重新加载生产工号 并验证登录状态
  390. loadData();
  391. //重置缺陷数据
  392. productionDefects = [];
  393. defectJson = [];
  394. defectCount = 0;
  395. $("[delbutton='true']").prop("disabled", false);
  396. procedureId = request('id');
  397. //加载产品信息
  398. $.get('api/GetCheckBarCode_WCF.ashx', { 'procedureid': procedureId, 'barcode': $('#产品条码').val() }, function (data) {
  399. var json = JSON.parse(data);
  400. if (json['success'] == true) {
  401. //打印条码
  402. //if (printBarcode) $('#barcodeImg').attr('src', 'print/barcodeimg.ashx?barcode=' + $('#产品条码').val());
  403. if (json['rows'][0]['out_errMsg'] == '') {
  404. //通过物料编码后续区分大件小件 20230223
  405. goodsModelForCheck = json['rows'][0]["GOODSMODELforCheck"];
  406. //读取产品信息
  407. $('#产品商标').val('商标:' + json['rows'][0]["out_logoName"]);
  408. $('#产品釉料').val('釉料:' + json['rows'][0]["out_glazeName"]);
  409. $('#产品编码').val('编码:' + json['rows'][0]["out_goodsCode"]);
  410. //$('#产品名称').val('名称:' + json['rows'][0]["out_goodsName"]);
  411. $('#漏气').val('漏气:' + json['rows'][0]["out_LeakFlag1Name"]);
  412. $('#内漏').val('内漏:' + json['rows'][0]["out_LeakFlag2Name"]);
  413. $('#通球').val('通球:' + json['rows'][0]["out_LeakFlag3Name"]);
  414. //设置漏气内漏通球样式 1合格0不合格
  415. $('#漏气').removeClass('bg-info,bg-warning');
  416. $('#内漏').removeClass('bg-info,bg-warning');
  417. $('#通球').removeClass('bg-info,bg-warning');
  418. if (json['rows'][0]["out_LeakFlag1"] == "1") $('#漏气').addClass('bg-info');
  419. if (json['rows'][0]["out_LeakFlag1"] == "0") $('#漏气').addClass('bg-warning');
  420. if (json['rows'][0]["out_LeakFlag2"] == "1") $('#内漏').addClass('bg-info');
  421. if (json['rows'][0]["out_LeakFlag2"] == "0") $('#内漏').addClass('bg-warning');
  422. if (json['rows'][0]["out_LeakFlag3"] == "1") $('#通球').addClass('bg-info');
  423. if (json['rows'][0]["out_LeakFlag3"] == "0") $('#通球').addClass('bg-warning');
  424. $('#重烧').val(json['rows'][0]["out_isReFireName"]);
  425. $('#干补').val(json['rows'][0]["out_specialRepairFlagName"]);
  426. $('#冷补').val(json['rows'][0]["out_lengBuName"]);
  427. //加载完成工序 判断 是 新建 还是 编辑
  428. $.get('api/GetCompleteProcedureIDPDA_WCF.ashx', { 'barcode': $('#产品条码').val() }, function (data) {
  429. var json = JSON.parse(data);
  430. if (json["success"] == true) {
  431. swal.close();
  432. completeProcedure = json["rows"];
  433. if (procedureId == completeProcedure[0]["COMPLETEPROCEDUREID"]) {
  434. checkFlag = "2";
  435. action = "update";
  436. loadUpdateData(0);
  437. }
  438. else {
  439. //2020-03-23 修正 回收后 再次成检 改判操作 找到正确的成检ID
  440. $.get('api/GetProductionDataCheckID_WCF.ashx', { 'barcode': $('#产品条码').val() }, function (data) {
  441. if (data == '{"success":true,"message":"操作成功!","rows":}') {
  442. data = '{"success":true,"message":"操作成功!","rows":""}';
  443. }
  444. var json = JSON.parse(data);
  445. if (json["success"] == true) {
  446. //2020-04-23 xuwei 修正
  447. if (json["rows"].length == 0) {
  448. //为空行时是新建
  449. checkFlag = "1";
  450. action = "insert";
  451. loadInsertData();
  452. }
  453. else {
  454. if (json["rows"][0]["PROCEDUREID"] == procedureId) {
  455. //工序相等时是更新
  456. checkFlag = "3";
  457. action = "update";
  458. loadUpdateData(json["rows"][0]["PRODUCTIONDATAID"]);
  459. }
  460. else {
  461. //工序不等时不可到达
  462. resetGoodsGrade(false);
  463. swal({
  464. title: "产品查询",
  465. text: "该工序不可到达!请确认质量登记工序!",
  466. icon: "error",
  467. button: "确定"
  468. }).then(function () {
  469. $('#产品条码').val('');
  470. $('#产品条码').focus();
  471. });
  472. }
  473. }
  474. //if (json["rows"][0]["PRODUCTIONDATAID"] != 0) {
  475. // checkFlag = "3";
  476. // action = "update";
  477. // loadUpdateData(json["rows"][0]["PRODUCTIONDATAID"]);
  478. //}
  479. //else {
  480. // checkFlag = "1";
  481. // action = "insert";
  482. // loadInsertData();
  483. //}
  484. }
  485. });
  486. }
  487. }
  488. });
  489. }
  490. else {
  491. resetGoodsGrade(false);
  492. swal({
  493. title: "产品查询",
  494. text: json['rows'][0]['out_errMsg'],
  495. icon: "error",
  496. button: "确定"
  497. }).then(function () {
  498. //条码无效时清空条码 2020-03-03 xuwei
  499. $('#产品条码').val('');
  500. $('#产品条码').focus();
  501. });
  502. }
  503. }
  504. else {
  505. swal({
  506. title: '登录异常!',
  507. text: '请您重新登录系统!',
  508. icon: 'error',
  509. button: '确定'
  510. }).then(function () {
  511. window.location = '/main/login/login.html';
  512. });
  513. }
  514. //产品缺陷列表清空
  515. ClearProductDefectList();
  516. });
  517. }
  518. //加载插入数据
  519. function loadInsertData() {
  520. //从预检(直接取在产表 tp_pm_inproduction)加载数据 xuwei add 2020-06-11 ======
  521. $.get('api/GetPreProductCheck.ashx?barCode=' + $('#产品条码').val(), function (data) {
  522. json = JSON.parse(data);
  523. var goodsLevelTypeId = 0;
  524. var reworkProcedureId = 0;
  525. if (json["success"] == true) {
  526. if (json["rows"].length > 0) {
  527. goodsLevelTypeId = json["rows"][0]["GOODSLEVELTYPEID"];
  528. reworkProcedureId = json["rows"][0]["REWORKPROCEDUREID"];
  529. }
  530. }
  531. //加载产品分级
  532. xuwell.loadSelect({
  533. id: '#产品分级',
  534. url: 'api/GetProductCheckGoodsGrade_WCF.ashx',
  535. data: {},
  536. fieldKey: 'DEFECTFLAGID',
  537. fieldValue: 'DEFECTFLAGNAME',
  538. onLoad: function (data) {
  539. $('#产品分级').get(0).selectedIndex = 0;
  540. if (goodsLevelTypeId > 0) $('#产品分级').val(goodsLevelTypeId);
  541. jsonGoodsLevel = data["rows"];
  542. //更新按钮状态
  543. goodsLevel_OnChange();
  544. //加载产品分级按钮
  545. if ($('#产品分级按钮').length > 0) {
  546. $('#产品分级按钮').html('');
  547. for (var i = 0; i < jsonGoodsLevel.length; i++) {
  548. var temp = $('#产品分级按钮模板').html().replaceAll('{id}', data["rows"][i]["DEFECTFLAGID"]).replaceAll('{text}', data["rows"][i]["DEFECTFLAGNAME"]);
  549. if (data["rows"][i]["DEFECTFLAGID"] != goodsLevelTypeId)
  550. temp = temp.replaceAll('active', '');
  551. $('#产品分级按钮').append(temp);
  552. }
  553. }
  554. }
  555. });
  556. //备注可用
  557. $('#产品分级').val('');
  558. //$('#备注').prop('disabled', false);
  559. });
  560. //=============================================================================
  561. }
  562. //加载编辑数据
  563. function loadUpdateData(productionDataCheckID) {
  564. if (action == "update") {
  565. //读取产品编辑ID
  566. $.get('api/GetProductionData_WCF.ashx', { 'BarCode': $('#产品条码').val(), 'ProcedureID': procedureId, 'userCode': $('#生产工号').val() }, function (data) {
  567. var json = JSON.parse(data);
  568. if (json["success"] == true) {
  569. //记录成检数据ID
  570. if (json["rows"].toString() != "") productionDataID = json["rows"][0]["PRODUCTIONDATAID"];
  571. //xuwei add 2020-03-23 回收后成检数据ID变更
  572. if (productionDataCheckID != 0) productionDataID = productionDataCheckID;
  573. //读取成检数据
  574. $.get('api/GetProductionDataByID_WCF.ashx', { 'productionDataID': productionDataID }, function (data) {
  575. swal.close();
  576. var json = JSON.parse(data);
  577. //读取产品信息 xuwei add 2020-03-23
  578. $('#产品商标').val('商标:' + json["rows"]["PDAProductionData"][0]["LogoName"]);
  579. $('#产品釉料').val('釉料:' + json["rows"]["PDAProductionData"][0]["GlazeName"]);
  580. $('#产品编码').val('编码:' + json["rows"]["PDAProductionData"][0]["GoodsCode"]);
  581. //$('#产品名称').val('名称:' + json["rows"]["PDAProductionData"][0]["GoodsName"]);
  582. //以checkbarcode为准不重新赋值
  583. //$('#重烧').val(json["rows"]["PDAProductionData"][0]["IsReFire"]);
  584. //$('#干补').val(json["rows"]["PDAProductionData"][0]["SpecialRepairflag"]);
  585. if (json["success"] == true) {
  586. //加载产品分级
  587. xuwell.loadSelect({
  588. id: '#产品分级',
  589. url: 'api/GetProductCheckGoodsGrade_WCF.ashx',
  590. data: {},
  591. fieldKey: 'DEFECTFLAGID',
  592. fieldValue: 'DEFECTFLAGNAME',
  593. onLoad: function (data) {
  594. $('#产品分级').val(json["rows"]["PDAProductionData"][0]["DefectFlagID"]);
  595. jsonGoodsLevel = data["rows"];
  596. //加载产品分级按钮
  597. if ($('#产品分级按钮').length > 0) {
  598. $('#产品分级按钮').html('');
  599. for (var i = 0; i < jsonGoodsLevel.length; i++) {
  600. var temp = $('#产品分级按钮模板').html().replaceAll('{id}', data["rows"][i]["DEFECTFLAGID"]).replaceAll('{text}', data["rows"][i]["DEFECTFLAGNAME"]);
  601. if (data["rows"][i]["DEFECTFLAGID"] != json["rows"]["PDAProductionData"][0]["DefectFlagID"])
  602. temp = temp.replaceAll('active', '');
  603. $('#产品分级按钮').append(temp);
  604. }
  605. }
  606. //判定是否超过改判时间
  607. $.get('api/GetSystemSettingDataByCode_WCF.ashx', function (data) {
  608. var json = JSON.parse(data);
  609. if (json["success"] == true) {
  610. var value = json["rows"][0]["SETTINGVALUE"];
  611. //判断是否超过改判时间
  612. //正常 value=0 是不限制 但是按PDA逻辑 使用接口再进行判定
  613. var createTime = jsonProductData["CreateTime"];
  614. $.post('api/BarcodeAllowCancel_WCF.ashx', { 'orgTime': createTime, 'days': value }, function (data) {
  615. var json = JSON.parse(data);
  616. if (json["success"] == true) {
  617. //更新按钮状态
  618. goodsLevel_OnChange();
  619. $('#产品分级保存按钮').prop('disabled', false);
  620. //$('#备注').prop('disabled', false);
  621. }
  622. else {
  623. $('#产品分级').prop("disabled", true);
  624. $("[delbutton='true']").prop("disabled", true);
  625. swal({
  626. title: "产品分级",
  627. text: "产品已过系统改判时间!",
  628. icon: "warning",
  629. button: "确定"
  630. });
  631. }
  632. });
  633. }
  634. });
  635. }
  636. });
  637. //加载分级数据
  638. //$('#备注').val(json["rows"]["PDAProductionData"][0]["Remarks"]);
  639. //记录修改数据
  640. jsonProductData = json["rows"]["PDAProductionData"][0];
  641. //加载缺陷数据
  642. var defect = json["rows"]["PDAProductionData"][0]["PDADefects"];
  643. for (var i = 0; i < defect.length; i++) {
  644. //更新数据模板并添加记录
  645. var temp = $('#缺陷列表模板').html();
  646. if (i == 0) $('#产品缺陷列表').empty();
  647. temp = temp.replaceAll('{缺陷标识}', i);
  648. temp = temp.replaceAll('{缺陷编码}', defect[i]["DefectCode"]);
  649. temp = temp.replaceAll('{缺陷名称}', defect[i]["DefectName"]);
  650. temp = temp.replaceAll('{位置编码}', defect[i]["DefectPositionCode"]);
  651. temp = temp.replaceAll('{缺陷位置}', defect[i]["DefectPositionName"]);
  652. temp = temp.replaceAll('{责任工序}', defect[i]["DefectProcedureName"]);
  653. temp = temp.replaceAll('{责任工号}', defect[i]["DefectUserCode"]);
  654. temp = temp.replaceAll('{责任工种}', defect[i]["Jobs"] + defect[i]["JobsText"]);
  655. temp = temp.replaceAll('{责任人}', getDefectUserNameFromDefect(defect[i]));
  656. temp = temp.replaceAll('{缺陷扣罚}', defect[i]["DefectFineValue"]);
  657. temp = temp.replaceAll('{扣除数}', defect[i]["DefectDeductionNum"]);
  658. temp = temp.replaceAll('{特殊缺陷}', defect[i]["SpecialDefect"]);
  659. $('#产品缺陷列表').append(temp);
  660. //加载缺陷数据用于提交
  661. productDefectLoadJson(defect[i]);
  662. }
  663. }
  664. });
  665. }
  666. });
  667. }
  668. }
  669. //产品分级 改变连动处理
  670. function goodsLevel_OnChange() {
  671. if ($("#产品分级").val() != '') {
  672. //重烧能选择返工工序
  673. if ($("#产品分级").find("option:selected").text() == '重烧') {
  674. $('#返工工序').prop('disabled', false);
  675. $('#返工工序').loadSelectFromData(procedureReFire);
  676. //通过物料编码区分大件小件 大件默认重烧工序为:【重烧接收】小件默认:【4-5重烧交接】 20230223
  677. if (goodsModelForCheck.substring(0, 2) == "CT") {
  678. $('#返工工序').val("138");
  679. }
  680. else {
  681. $('#返工工序').val("57");
  682. }
  683. $('#返工工序').prop('disabled', true);
  684. //$('#返工工序').get(0).selectedIndex = 1;
  685. }
  686. //冷补能选择返工工序
  687. else if ($("#产品分级").find("option:selected").text() == '冷补') {
  688. $('#返工工序').prop('disabled', false);
  689. $('#返工工序').loadSelectFromData(procedureLengbu);
  690. $('#返工工序').get(0).selectedIndex = 1;
  691. }
  692. else {
  693. $('#返工工序').prop('disabled', true);
  694. $("#返工工序").val('');
  695. }
  696. //缺陷页控制
  697. if ($("#产品分级").find("option:selected").text() == '正品') {
  698. //如果有缺陷记录要确认是否删除
  699. if (productionDefects.length > 0) {
  700. swal({
  701. title: "产品分级",
  702. text: "产品分级改判为正品,必须除缺陷记录!",
  703. icon: "warning",
  704. buttons: true,
  705. dangerMode: true,
  706. buttons: ["取消", "删除缺陷记录"]
  707. }).then((ok) => {
  708. if (ok) {
  709. $("#返工工序").val('');
  710. $('#返工工序').prop('disabled', true);
  711. //产品缺陷列表清空
  712. ClearProductDefectList();
  713. resetSaveButton();
  714. }
  715. });
  716. }
  717. else {
  718. //产品缺陷列表清空
  719. ClearProductDefectList();
  720. }
  721. }
  722. else {
  723. $('#产品分级保存按钮').prop('disabled', true);
  724. }
  725. //更新保存按钮
  726. resetSaveButton();
  727. }
  728. else {
  729. $('#产品分级保存按钮').prop('disabled', true);
  730. }
  731. }
  732. //启用禁用 产品分级 保存按钮
  733. function resetSaveButton() {
  734. //保存按钮控制 正品没有缺陷记录可保存,非正品必须有缺陷记录才可保存
  735. if ($("#产品分级").find("option:selected").text() == '正品') {
  736. if (productionDefects.length == 0)
  737. $('#产品分级保存按钮').prop('disabled', false);
  738. else
  739. $('#产品分级保存按钮').prop('disabled', true);
  740. //重置产品缺陷选择
  741. resetProductDefect(true);
  742. }
  743. else {
  744. if (productionDefects.length > 0)
  745. $('#产品分级保存按钮').prop('disabled', false);
  746. else
  747. $('#产品分级保存按钮').prop('disabled', true);
  748. //重置产品缺陷选择
  749. resetProductDefect(false);
  750. }
  751. }
  752. //启用禁用 产品分级 页
  753. function resetGoodsGrade(clearBarCode) {
  754. //产品信息清空
  755. $('#产品商标').val('');
  756. $('#产品釉料').val('');
  757. $('#产品编码').val('');
  758. //$('#产品名称').val('');
  759. $('#重烧').val('');
  760. $('#干补').val('');
  761. //产品分级选项清空禁用
  762. $("#产品分级按钮").children().removeClass("active");
  763. $('#产品分级').val('');
  764. $('#产品分级').prop('disabled', true);
  765. $('#返工工序').val('');
  766. $('#返工工序').prop('disabled', true);
  767. //$('#备注').val('');
  768. //$('#备注').prop('disabled', true);
  769. $('#产品分级保存按钮').prop('disabled', true);
  770. //产品缺陷禁用
  771. resetProductDefect(true);
  772. if (clearBarCode) $('#产品条码').val('');
  773. $('#产品条码').focus();
  774. }
  775. //启用禁用 产品缺陷 页
  776. function resetProductDefect(disabled) {
  777. if (disabled) {
  778. $('#缺陷名称').val('');
  779. $('#选择缺陷按钮').prop('disabled', true);
  780. $('#缺陷位置').val('');
  781. $('#选择位置按钮').prop('disabled', true);
  782. $('#特殊缺陷').val('');
  783. $('#特殊缺陷').prop('disabled', true);
  784. $('#责任工序').val('');
  785. $('#责任工序').prop('disabled', true);
  786. $('#责任工号').val('');
  787. $('#责任工号').prop('disabled', true);
  788. $('#责任工号按钮').prop('disabled', true);
  789. $('#责任工种').val('');
  790. $('#责任工种').prop('disabled', true);
  791. $('#责任人').val('');
  792. $('#责任人').prop('disabled', true);
  793. $('#责任人').selectpicker('refresh');
  794. $('#缺陷扣罚').val('');
  795. $('#缺陷扣罚').prop('disabled', true);
  796. $('#扣除数').val('');
  797. $('#扣除数').prop('disabled', true);
  798. $('#产品缺陷保存按钮').prop('disabled', true);
  799. //$('#产品缺陷保存按钮多次').prop('disabled', true);
  800. }
  801. else {
  802. $('#缺陷名称').val('');
  803. $('#选择缺陷按钮').prop('disabled', false);
  804. $('#缺陷位置').val('');
  805. $('#选择位置按钮').prop('disabled', false);
  806. $('#特殊缺陷').val('');
  807. //$('#特殊缺陷').prop('disabled', false);
  808. $('#责任工序').val('');
  809. //$('#责任工序').prop('disabled', false);
  810. $('#责任工号').val('');
  811. //$('#责任工号').prop('disabled', false);
  812. //$('#责任工号按钮').prop('disabled', false);
  813. $('#责任工种').val('');
  814. //$('#责任工种').prop('disabled', false);
  815. $('#责任人').val('');
  816. //$('#责任人').prop('disabled', false);
  817. $('#责任人').selectpicker('refresh');
  818. $('#缺陷扣罚').val('');
  819. //$('#缺陷扣罚').prop('disabled', false);
  820. $('#扣除数').val('');
  821. //$('#扣除数').prop('disabled', false);
  822. $('#产品缺陷保存按钮').prop('disabled', true);
  823. //$('#产品缺陷保存按钮多次').prop('disabled', true);
  824. }
  825. //中陶 只有一个缺陷位置 默认选中第一项=================
  826. if (productDefectPositionData['rows'].length > 0) {
  827. productDefectPositionId = productDefectPositionData['rows'][0]['DEFECTPOSITIONID'];
  828. productDefectPositionCode = productDefectPositionData['rows'][0]['DEFECTPOSITIONCODE'];
  829. productDefectPositionName = productDefectPositionData['rows'][0]['DEFECTPOSITIONNAME'];
  830. $('#缺陷位置').val(productDefectPositionName);
  831. }
  832. //=======================================================
  833. }
  834. //加载 责任工序
  835. function loadDefectProcedure() {
  836. //加载责任工序
  837. xuwell.loadSelect({
  838. id: '#责任工序',
  839. url: 'api/GetDutyProcedureByBarCode_WCF.ashx',
  840. data: {
  841. 'barcode': $('#产品条码').val(),
  842. 'defectid': productDefectId
  843. },
  844. fieldKey: 'DUTYPROCEDUREID',
  845. fieldValue: 'DUTYPROCEDURENAME',
  846. onLoad: function (data) {
  847. jsonProcedure = data['rows'];
  848. }
  849. });
  850. //加载缺限扣罚
  851. xuwell.loadSelect({
  852. id: '#缺陷扣罚',
  853. //url: 'api/GetAllDefectFine_WCF.ashx',
  854. url: 'api/GetDefectFine.ashx',
  855. data: { 'defectid': productDefectId },
  856. fieldKey: 'DEFECTFINEID',
  857. fieldValue: 'DEFECTFINECODE',
  858. onLoad: function () {
  859. $('#缺陷扣罚').get(0).selectedIndex = 1;
  860. }
  861. });
  862. //加载扣除数
  863. xuwell.loadSelect({
  864. id: '#扣除数',
  865. //url: 'api/GetAllDefectDeduction_WCF.ashx',
  866. url: 'api/GetDefectDeduction.ashx',
  867. data: { 'defectid': productDefectId },
  868. fieldKey: 'DEFECTDEDUCTIONID',
  869. fieldValue: 'DEFECTDEDUCTIONNUM',
  870. onLoad: function () {
  871. $('#扣除数').get(0).selectedIndex = 1;
  872. }
  873. });
  874. $('#特殊缺陷').val('0');
  875. $('#特殊缺陷').prop('disabled', false);
  876. $('#责任工号按钮').prop('disabled', false);
  877. $('#责任工号').prop('disabled', false);
  878. $('#责任工号').val('');
  879. $('#责任工种').prop('disabled', true);
  880. $('#责任工种').val('');
  881. $('#责任人').prop('disabled', true);
  882. $('#责任人').val('');
  883. }
  884. //责任工序 改变连动处理
  885. function defectProcedure_OnChange() {
  886. var selectIndex = $('#责任工序').prop("selectedIndex");
  887. if (selectIndex > 0) {
  888. //加载责任工号
  889. $('#责任工号按钮').prop('disabled', true);
  890. $('#责任工号').prop('disabled', true);
  891. $('#责任工号').val(jsonProcedure[selectIndex - 1]['USERCODE']);
  892. defectUserId = jsonProcedure[selectIndex - 1]['USERID'];
  893. //加载责任工种
  894. xuwell.loadSelect({
  895. id: '#责任工种',
  896. url: 'api/GetDutyJobsByUserIDAndProductionID_WCF.ashx',
  897. data: {
  898. 'classesSettingID': jsonProcedure[selectIndex - 1]['CLASSESSETTINGID'],
  899. 'defectid': productDefectId,
  900. 'procedureID': jsonProcedure[selectIndex - 1]['DUTYPROCEDUREID']
  901. },
  902. fieldKey: 'JOBSID',
  903. fieldValue: 'JOBSNAME',
  904. onLoad: function (data) {
  905. $('#责任工种').get(0).selectedIndex = 1;
  906. }
  907. });
  908. //加载责任人
  909. xuwell.loadSelect({
  910. id: '#责任人',
  911. url: 'api/GetDutyStaffByUserIDAndJobs_WCF.ashx',
  912. data: {
  913. 'classesSettingID': jsonProcedure[selectIndex - 1]['CLASSESSETTINGID'],
  914. 'jobsid': jsonProcedure[selectIndex - 1]['JOBSID']
  915. },
  916. fieldKey: 'STAFFID',
  917. fieldValue: 'STAFFNAME',
  918. addTitle: false,
  919. onLoad: function (data) {
  920. jsonStaff = data["rows"];
  921. //$('#责任人').get(0).selectedIndex = '1,2';
  922. $("#责任人").selectpicker({
  923. selectedTextFormat: 'values',
  924. });
  925. $('#责任人').selectpicker('refresh');
  926. $('#责任人').selectpicker('selectAll');
  927. }
  928. });
  929. }
  930. else {
  931. $('#责任工号按钮').prop('disabled', false);
  932. $('#责任工号').prop('disabled', false);
  933. $('#责任工号').val('');
  934. $('#责任工种').prop('disabled', true);
  935. $('#责任工种').val('');
  936. $('#责任人').prop('disabled', true);
  937. //$('#责任人').val('');
  938. $('#责任人').selectpicker('val', []);
  939. }
  940. }
  941. //加载 责任工种 从 责任工号(无责任)
  942. function loadDefectByUserCode() {
  943. //查找userId
  944. $.get('api/GetUserCode_WCF.ashx', { 'usercode': $('#责任工号').val() }, function (data) {
  945. var json = JSON.parse(data);
  946. if (json['success'] == true && json['rows'].length > 0) {
  947. userId = json['rows'][0]['USERID'];
  948. defectUserId = json['rows'][0]['USERID'];
  949. //加载责任工种
  950. xuwell.loadSelect({
  951. id: '#责任工种',
  952. url: 'api/GetAllJobsByUserID_WCF.ashx',
  953. data: { 'userid': userId },
  954. fieldKey: 'JOBS',
  955. fieldValue: 'JOBSNAME',
  956. onLoad: function (data) {
  957. $('#责任工种').get(0).selectedIndex = 1;
  958. //加载责任人
  959. defectJobs_OnChange();
  960. }
  961. });
  962. }
  963. else {
  964. swal({
  965. title: "工号查询",
  966. text: "工号不正确!",
  967. icon: "error",
  968. button: "确定"
  969. });
  970. }
  971. });
  972. }
  973. //责任工种 改变连动处理
  974. function defectJobs_OnChange() {
  975. //没有选择责任工序 通过责任工种 查找 责任人
  976. if ($('#责任工序').val() == '') {
  977. //加载责任人
  978. if ($('#责任工种').val() != '') {
  979. xuwell.loadSelect({
  980. id: '#责任人',
  981. url: 'api/GetDutyStaffByUserJobsID_WCF.ashx',
  982. data: {
  983. 'userid': userId,
  984. 'jobs': $('#责任工种').val()
  985. },
  986. fieldKey: 'STAFFID',
  987. fieldValue: 'STAFFNAME',
  988. addTitle: false,
  989. onLoad: function (data) {
  990. jsonStaff = data["rows"];
  991. //$('#责任人').get(0).selectedIndex = 1;
  992. $('#责任人').selectpicker('refresh');
  993. $('#责任人').selectpicker('selectAll');
  994. },
  995. onError: function () {
  996. $('#责任人').val('');
  997. $('#责任人').prop('disabled', true);
  998. $('#责任人').selectpicker('refresh');
  999. }
  1000. });
  1001. }
  1002. else {
  1003. $('#责任人').val('');
  1004. $('#责任人').prop('disabled', true);
  1005. $('#责任人').selectpicker('refresh');
  1006. }
  1007. }
  1008. }
  1009. //单次保存
  1010. function productDefectSaveOne() {
  1011. if (productDefectSave()) {
  1012. //重设缺陷编辑状态 可继续添加缺陷
  1013. resetProductDefect(true);
  1014. //$('#缺陷名称').val('');
  1015. $('#选择缺陷按钮').prop('disabled', false);
  1016. //$('#缺陷位置').val('');
  1017. $('#选择位置按钮').prop('disabled', false);
  1018. //更新产品分级保存按钮
  1019. $('#产品分级保存按钮').prop('disabled', false);
  1020. }
  1021. }
  1022. //多次保存
  1023. function productDefectSaveMore() {
  1024. if (productDefectSave()) {
  1025. $('#责任工序').val('');
  1026. defectProcedure_OnChange();
  1027. //更新产品分级保存按钮
  1028. $('#产品分级保存按钮').prop('disabled', false);
  1029. }
  1030. }
  1031. //保存产品缺陷记录处理
  1032. function productDefectSave() {
  1033. //校验填写数据
  1034. if ($('#缺陷名称').val() == '') {
  1035. swal({
  1036. title: "产品缺陷",
  1037. text: '请您选择缺陷名称!',
  1038. icon: "error",
  1039. button: "确定"
  1040. });
  1041. return false;
  1042. }
  1043. if ($('#缺陷位置').val() == '') {
  1044. swal({
  1045. title: "产品缺陷",
  1046. text: '请您选择缺陷位置!',
  1047. icon: "error",
  1048. button: "确定"
  1049. });
  1050. return false;
  1051. }
  1052. if ($('#责任工序').val() == '' && $('#责任工号').val() == '') {
  1053. swal({
  1054. title: "产品缺陷",
  1055. text: '请您选择责任工序或者填写责任工号!',
  1056. icon: "error",
  1057. button: "确定"
  1058. });
  1059. return false;
  1060. }
  1061. if ($('#责任工种').val() == '') {
  1062. swal({
  1063. title: "产品缺陷",
  1064. text: '请您选择责任工种!',
  1065. icon: "error",
  1066. button: "确定"
  1067. });
  1068. return false;
  1069. }
  1070. if ($('#责任人').val() == '') {
  1071. swal({
  1072. title: "产品缺陷",
  1073. text: '请您选择责任人!',
  1074. icon: "error",
  1075. button: "确定"
  1076. });
  1077. return false;
  1078. }
  1079. if ($('#缺陷扣罚').val() == '') {
  1080. swal({
  1081. title: "产品缺陷",
  1082. text: '请您选择缺陷扣罚!',
  1083. icon: "error",
  1084. button: "确定"
  1085. });
  1086. return false;
  1087. }
  1088. if ($('#扣除数').val() == '') {
  1089. swal({
  1090. title: "产品缺陷",
  1091. text: '请您选择扣除数!',
  1092. icon: "error",
  1093. button: "确定"
  1094. });
  1095. return false;
  1096. }
  1097. if ($('#特殊缺陷').val() == '') {
  1098. swal({
  1099. title: "产品缺陷",
  1100. text: '请您选择特殊缺陷!',
  1101. icon: "error",
  1102. button: "确定"
  1103. });
  1104. return false;
  1105. }
  1106. //判断缺陷是否重复 2020-04-24
  1107. for (var i = 0; i < productionDefects.length; i++) {
  1108. if (
  1109. productionDefects[i]["DefectID"] == productDefectId
  1110. && productionDefects[i]["DefectProcedureID"] == ($('#责任工序').val() == "" ? null : $('#责任工序').val())
  1111. && productionDefects[i]["DefectUserCode"] == $("#责任工号").val()
  1112. ) {
  1113. swal({
  1114. title: "产品缺陷",
  1115. text: '缺陷重复,不允许添加!',
  1116. icon: "error",
  1117. button: "确定"
  1118. });
  1119. return false;
  1120. }
  1121. }
  1122. //更新数据模板并添加记录
  1123. var temp = $('#缺陷列表模板').html();
  1124. if (defectCount == 0) $('#产品缺陷列表').empty();
  1125. temp = temp.replaceAll('{缺陷标识}', defectCount);
  1126. temp = temp.replaceAll('{缺陷编码}', productDefectCode);
  1127. temp = temp.replaceAll('{缺陷名称}', $('#缺陷名称').val());
  1128. temp = temp.replaceAll('{位置编码}', productDefectPositionCode);
  1129. temp = temp.replaceAll('{缺陷位置}', $('#缺陷位置').val());
  1130. temp = temp.replaceAll('{责任工序}', $("#责任工序").val() == '' ? '' : $("#责任工序").find("option:selected").text());
  1131. temp = temp.replaceAll('{责任工号}', $('#责任工号').val());
  1132. temp = temp.replaceAll('{责任工种}', $('#责任工种').val() + $('#责任工种').find("option:selected").text());
  1133. temp = temp.replaceAll('{责任人}', getDefectUserName());
  1134. temp = temp.replaceAll('{缺陷扣罚}', $('#缺陷扣罚').find("option:selected").text());
  1135. temp = temp.replaceAll('{扣除数}', $('#扣除数').find("option:selected").text());
  1136. temp = temp.replaceAll('{特殊缺陷}', $('#特殊缺陷').find("option:selected").text());
  1137. $('#产品缺陷列表').append(temp);
  1138. //保存缺陷数据
  1139. productDefectSaveJson();
  1140. return true;
  1141. }
  1142. //保存产品缺陷记录拼合处理
  1143. function productDefectSaveJson() {
  1144. //定义缺陷责任
  1145. var defectResponsibles = [];
  1146. //获取责任人
  1147. console.log($("#责任人").selectpicker('val'));
  1148. console.log(jsonStaff);
  1149. for (var i = 0; i < jsonStaff.length; i++) {
  1150. if ($("#责任人").selectpicker('val').indexOf(jsonStaff[i]["STAFFID"].toString()) >= 0) {
  1151. var defectOne = {
  1152. "UserID": defectUserId,
  1153. "UserCode": $("#责任工号").val(),
  1154. "SJobsID": jsonStaff[i]["SJOBSID"],
  1155. "StaffStatus": jsonStaff[i]["STAFFSTATUS"],
  1156. "StaffID": jsonStaff[i]["STAFFID"],
  1157. "UJobsID": $("#责任工种").val()
  1158. }
  1159. //如果是更新
  1160. if (action == "update") {
  1161. if (jsonProductData["PDADefects"].length > 0)
  1162. defectOne["PDACheckTime"] = jsonProductData["PDADefects"][0]["CheckTime"];
  1163. }
  1164. defectResponsibles.push(defectOne);
  1165. }
  1166. }
  1167. //定义缺陷数据
  1168. var productionOne = {
  1169. "DefectID": productDefectId,
  1170. "DefectCode": productDefectCode,
  1171. "DefectName": productDefectName,
  1172. "DefectPositionID": productDefectPositionId,
  1173. "DefectPositionCode": productDefectPositionCode,
  1174. "DefectPositionName": productDefectPositionName,
  1175. "DefectProcedureID": $('#责任工序').val() == "" ? null : $('#责任工序').val(),
  1176. "DefectProcedureCode": $('#责任工序').val() != "" ? jsonProcedure[$('#责任工序').get(0).selectedIndex - 1]["DUTYPROCEDURECODE"] : "",
  1177. "DefectProcedureName": $('#责任工序').val() != "" ? $("#责任工序").find("option:selected").text() : "",
  1178. "DefectUserID": $('#责任工序').val() != "" ? jsonProcedure[$('#责任工序').get(0).selectedIndex - 1]["USERID"] : defectUserId,
  1179. "DefectUserCode": $("#责任工号").val(),
  1180. "DefectUserName": $('#责任工序').val() != "" ? jsonProcedure[$('#责任工序').get(0).selectedIndex - 1]["USERNAME"] : "",
  1181. "DefectJobs": $("#责任工种").val(),
  1182. "DefectFine": $("#缺陷扣罚").val(),
  1183. "DefectDeductionNum": $("#扣除数").val(),
  1184. "SpecialDefect": $("#特殊缺陷").val(),
  1185. "IsPDA": "1",
  1186. "DefectResponsibles": defectResponsibles,
  1187. }
  1188. //如果是更新
  1189. if (action == "update") {
  1190. if (jsonProductData["PDADefects"].length > 0)
  1191. productionOne["PDACheckTime"] = jsonProductData["PDADefects"][0]["CheckTime"];
  1192. }
  1193. productionDefects.push(productionOne);
  1194. defectCount++;
  1195. }
  1196. //加载产品缺陷记录从编辑数据
  1197. function productDefectLoadJson(json) {
  1198. console.log(json);
  1199. //定义缺陷责任
  1200. var defectResponsibles = [];
  1201. for (var i = 0; i < json["PDADefectResponsibles"].length; i++) {
  1202. var defectOne = {
  1203. "UserID": json["DefectUserID"],
  1204. "UserCode": json["DefectUserCode"],
  1205. "SJobsID": json["PDADefectResponsibles"][i]["SJobsID"],
  1206. "StaffStatus": json["PDADefectResponsibles"][i]["StaffStatus"],
  1207. "StaffID": json["PDADefectResponsibles"][i]["StaffID"],
  1208. "UJobsID": json["PDADefectResponsibles"][i]["UJobsID"],
  1209. //只有编辑时使用
  1210. "PDACheckTime": json["CheckTime"]
  1211. }
  1212. defectResponsibles.push(defectOne);
  1213. }
  1214. //定义缺陷数据
  1215. var productionOne = {
  1216. "DefectID": json["DefectID"],
  1217. "DefectCode": json["DefectCode"],
  1218. "DefectName": json["DefectName"],
  1219. "DefectPositionID": json["DefectPositionID"],
  1220. "DefectPositionCode": json["DefectPositionCode"],
  1221. "DefectPositionName": json["DefectPositionName"],
  1222. "DefectProcedureID": json["DefectProcedureID"],
  1223. "DefectProcedureCode": json["DefectProcedureCode"],
  1224. "DefectProcedureName": json["DefectProcedureName"],
  1225. "DefectUserID": json["DefectUserID"],
  1226. "DefectUserCode": json["DefectUserCode"],
  1227. "DefectUserName": json["DefectUserName"],
  1228. "DefectJobs": json["Jobs"].toString(),
  1229. "DefectFine": json["DefectFineID"],
  1230. "DefectDeductionNum": json["DefectDeductionNum"],
  1231. "SpecialDefect": json["SpecialDefect"],
  1232. "IsPDA": "1",
  1233. "DefectResponsibles": defectResponsibles,
  1234. //只有编辑时使用
  1235. "PDACheckTime": json["CheckTime"]
  1236. }
  1237. productionDefects.push(productionOne);
  1238. defectCount++;
  1239. }
  1240. //获取责任人多选值用|分隔 从当前选项
  1241. function getDefectUserName() {
  1242. var s = $("#责任人").find("option:selected");
  1243. var username = "";
  1244. for (var i = 0; i < s.length; i++) {
  1245. if (i > 0) username += "|";
  1246. username += $("#责任人").find("option:selected")[i].innerText;
  1247. }
  1248. return username;
  1249. }
  1250. //获取责任人多选值用|分隔 从数据
  1251. function getDefectUserNameFromDefect(json) {
  1252. var username = "";
  1253. for (var i = 0; i < json["PDADefectResponsibles"].length; i++) {
  1254. if (username != "") username += "|";
  1255. username += json["PDADefectResponsibles"][i]["StaffName"]
  1256. }
  1257. return username;
  1258. }
  1259. //删除缺陷记录按钮处理
  1260. function productDefectDelete(id) {
  1261. swal({
  1262. title: "产品缺陷",
  1263. text: "您确定要删除缺陷记录吗?",
  1264. icon: "warning",
  1265. buttons: true,
  1266. dangerMode: true,
  1267. buttons: ["取消", "确定"]
  1268. }).then((save) => {
  1269. if (save) {
  1270. $('#' + id).remove();
  1271. productionDefects.splice(parseInt(id), 1);
  1272. defectCount--;
  1273. if (defectCount == 0) {
  1274. ClearProductDefectList();
  1275. //更新产品分级保存按钮
  1276. resetSaveButton();
  1277. }
  1278. }
  1279. });
  1280. }
  1281. //选择缺陷按钮点击处理
  1282. function productDefect_OnClick(id) {
  1283. dialogDefectShow(function () {
  1284. $('#缺陷名称').val(productDefectName);
  1285. loadDefectProcedure();
  1286. $('#产品缺陷保存按钮').prop('disabled', false);
  1287. //$('#产品缺陷保存按钮多次').prop('disabled', false);
  1288. });
  1289. }
  1290. //选择缺陷位置按钮点击处理
  1291. function productDefectPosition_OnClick(id) {
  1292. dialogDefectPositionShow(function () {
  1293. $('#缺陷位置').val(productDefectPositionName);
  1294. //loadDefectProcedure();
  1295. //$('#产品缺陷保存按钮').prop('disabled', false);
  1296. //$('#产品缺陷保存按钮多次').prop('disabled', false);
  1297. });
  1298. }
  1299. //保存产品分级
  1300. function productSave() {
  1301. //校验填写数据
  1302. if ($("#产品分级").val() == '') {
  1303. swal({
  1304. title: "产品分级",
  1305. text: "请您选择产品分级!",
  1306. icon: "error",
  1307. button: "确定"
  1308. });
  1309. return;
  1310. }
  1311. if ($("#产品分级").find("option:selected").text() == '正品' && productionDefects.length > 0) {
  1312. swal({
  1313. title: "产品分级",
  1314. text: "产品分级为正品,不能有缺陷记录!",
  1315. icon: "error",
  1316. button: "确定"
  1317. });
  1318. return;
  1319. }
  1320. if ($("#产品分级").find("option:selected").text() != '正品' && productionDefects.length == 0) {
  1321. swal({
  1322. title: "产品分级",
  1323. text: "产品分级为非正品,必须填写缺陷记录!",
  1324. icon: "error",
  1325. button: "确定"
  1326. });
  1327. return;
  1328. }
  1329. if ($("#产品分级").find("option:selected").text() == '重烧' && $("#返工工序").val() == '') {
  1330. swal({
  1331. title: "产品分级",
  1332. text: "请您选择返工工序!",
  1333. icon: "error",
  1334. button: "确定"
  1335. });
  1336. return;
  1337. }
  1338. if ($("#产品分级").find("option:selected").text() == '冷补' && $("#返工工序").val() == '') {
  1339. swal({
  1340. title: "产品分级",
  1341. text: "请您选择返工工序!",
  1342. icon: "error",
  1343. button: "确定"
  1344. });
  1345. return;
  1346. }
  1347. //保存产品分级 带确认提示
  1348. //swal({
  1349. // title: "产品分级",
  1350. // text: "您确定要保存产品分级数据吗?",
  1351. // icon: "warning",
  1352. // dangerMode: true,
  1353. // buttons: ["取消","确定"]
  1354. //}).then((ok) => {
  1355. // if (ok) {
  1356. // swal({
  1357. // title: '产品分级',
  1358. // text: '正在保存数据,请稍候。。。',
  1359. // icon: 'info',
  1360. // button: false,
  1361. // closeOnClickOutside: false
  1362. // });
  1363. // save(ok);
  1364. // }
  1365. //});
  1366. //保存产品分级 不带确认提示
  1367. swal({
  1368. title: '产品分级',
  1369. text: '正在保存数据,请稍候。。。',
  1370. icon: 'info',
  1371. button: false,
  1372. closeOnClickOutside: false
  1373. });
  1374. save(true);
  1375. }
  1376. function save(ok) {
  1377. if (ok) {
  1378. //生成时间戳避免重复提交
  1379. var dataKey = new Date().getTime() + '-' + $('#生产工号').val();
  1380. console.log(dataKey);
  1381. var productionDataEntitys;
  1382. //拼合插入数据
  1383. if (action == "insert") {
  1384. productionDataEntitys = [{
  1385. "DataKey": dataKey,
  1386. "CheckFlag": checkFlag,
  1387. "UserID": jsonUser["userId"],
  1388. "UserCode": jsonUser["userCode"],
  1389. "UserName": jsonUser["userName"],
  1390. "Barcode": $('#产品条码').val(),
  1391. "GoodsLevelID": jsonGoodsLevel[$('#产品分级').get(0).selectedIndex - 1]["DEFECTFLAGID"],
  1392. "GoodsLevelTypeID": jsonGoodsLevel[$('#产品分级').get(0).selectedIndex - 1]["GOODSLEVELTYPEID"],
  1393. "ReworkProcedureID": parseInt($('#返工工序').val()),
  1394. "ReworkProcedureName": $('#返工工序').val() == "" ? "" : $("#返工工序").find("option:selected").text(),
  1395. "DefectFlag": $("#产品分级").find("option:selected").text() == "正品" ? 1 : 2,
  1396. "Remarks": "",
  1397. "IsPDA": 1,
  1398. "ProductionDefects": productionDefects,
  1399. "OPTimeStampPDA": completeProcedure[0]["CONVERTOPTIMESTAMP"]
  1400. }];
  1401. }
  1402. //拼合更新数据
  1403. if (action == "update") {
  1404. productionDataEntitys = [{
  1405. "DataKey": dataKey,
  1406. "CheckFlag": checkFlag,
  1407. "UserID": jsonUser["userId"],
  1408. "UserCode": jsonUser["userCode"],
  1409. "UserName": jsonUser["userName"],
  1410. "Barcode": $('#产品条码').val(),
  1411. "GoodsLevelID": jsonGoodsLevel[$('#产品分级').get(0).selectedIndex - 1]["DEFECTFLAGID"],
  1412. "GoodsLevelTypeID": jsonGoodsLevel[$('#产品分级').get(0).selectedIndex - 1]["GOODSLEVELTYPEID"],
  1413. "ReworkProcedureID": parseInt($('#返工工序').val()),
  1414. "ReworkProcedureName": $('#返工工序').val() == "" ? "" : $("#返工工序").find("option:selected").text(),
  1415. "DefectFlag": $("#产品分级").find("option:selected").text() == "正品" ? 1 : 2,
  1416. "Remarks": "",
  1417. "IsPDA": 1,
  1418. "ProductionDefects": productionDefects,
  1419. "OPTimeStampPDA": completeProcedure[0]["CONVERTOPTIMESTAMP"],
  1420. //只有编辑时使用
  1421. "ProductionDataID": productionDataID,
  1422. "PDACheckTime": jsonProductData["CheckTime"],
  1423. "OrgGoodsLevelTypeID": jsonProductData["GoodsLevelTypeID"]
  1424. }];
  1425. }
  1426. //提交到接口
  1427. $.post('api/AddCheckBarcode_WCF.ashx', { 'procedureID': procedureId, 'productionDataEntitys': JSON.stringify(productionDataEntitys), 'barcode': $('#产品条码').val() }, function (data) {
  1428. var json = JSON.parse(data);
  1429. if (json['success'] == true ) {
  1430. //打印条码
  1431. //if (printBarcode) {
  1432. // if ($("#产品分级").find("option:selected").text() == "正品"
  1433. // || $("#产品分级").find("option:selected").text() == "副品"
  1434. // ) {
  1435. // console.log(jsonGoodsLevel[$('#产品分级').get(0).selectedIndex - 1]["GOODSLEVELTYPEID"]);
  1436. // $("#printBarcode").jqprint({
  1437. // debug: false,
  1438. // importCSS: false,
  1439. // printContainer: false,
  1440. // operaSupport: false
  1441. // });
  1442. // //$("#barcodeImg").print();
  1443. // }
  1444. //}
  1445. //保存成功
  1446. swal("保存成功!", {
  1447. title: '产品分级',
  1448. icon: 'success',
  1449. buttons: false,
  1450. timer: 2000,
  1451. }).then(() => {
  1452. $("#产品条码").focus();
  1453. });
  1454. //清空数据,继续下次成检
  1455. resetGoodsGrade(true);
  1456. //产品缺陷列表清空
  1457. ClearProductDefectList();
  1458. }
  1459. else {
  1460. if (json['message'] == '重复提交') {
  1461. //重复提交不做任何处理 2020-06-28 xuwei
  1462. }
  1463. else {
  1464. //保存失败
  1465. swal({
  1466. title: "产品分级",
  1467. text: '保存失败!' + json['message'] ,
  1468. icon: "error",
  1469. button: "确定"
  1470. });
  1471. }
  1472. }
  1473. });
  1474. }
  1475. }
  1476. </script>
  1477. <!--打印条码-->
  1478. <!--<script src="print/jquery.jqprint-0.3.js"></script>-->
  1479. <!--<div id="printBarcode" style="background-color:white;display:none">
  1480. <img id="barcodeImg"/>
  1481. </div>-->
  1482. </body>
  1483. </html>