indexOK.html 75 KB

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