You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

321 lines
14 KiB

3 weeks ago
  1. 
  2. @{
  3. ViewBag.Title = "";
  4. Layout = "~/Views/Shared/_Form.cshtml";
  5. }
  6. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  7. <!--引入 element-ui 的样式,-->
  8. <link rel="stylesheet" href="~/Content/element-ui/lib/theme-chalk/index.css">
  9. <script src="~/Content/vue/dist/vue.js"></script>
  10. <script src="~/Content/element-ui/lib/index.js"></script>
  11. <script src="~/Content/axios.min.js"></script>
  12. <style>
  13. </style>
  14. <form id="form1">
  15. <div id="app">
  16. <template>
  17. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  18. <el-divider>主表信息</el-divider>
  19. <el-row :gutter="24">
  20. <el-col :span="6">
  21. <el-form-item label="Aql编码" prop="RulesCode">
  22. <el-input v-model="form.RulesCode" placeholder="请输入内容" size="mini" :disabled="disabled4RulesCode"></el-input>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="6">
  26. <el-form-item label="Aql名称" prop="RulesName">
  27. <el-input v-model="form.RulesName" placeholder="请输入内容" size="mini"></el-input>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="Aql描述" prop="RulesDesc">
  32. <el-input v-model="form.RulesDesc" placeholder="请输入内容" size="mini"></el-input>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="6">
  36. <el-form-item label="Aql类别" prop="Type">
  37. <el-input v-model="form.Type" placeholder="请输入内容" size="mini"></el-input>
  38. </el-form-item>
  39. </el-col>
  40. </el-row>
  41. <el-row :gutter="24">
  42. <el-col :span="6">
  43. <el-form-item label="启用" prop="Enable">
  44. <el-switch v-model="form.Enable" active-color="#13ce66" inactive-color="#ff4949">
  45. </el-switch>
  46. </el-form-item>
  47. </el-col>
  48. </el-row>
  49. <el-divider>子表信息</el-divider>
  50. <el-row :gutter="24">
  51. <el-col :span="24">
  52. @*<el-button type="primary" size="mini" v-on:click="addLine()">新增</el-button>*@
  53. <a id="NF-Add" authorize="no" style="margin-left:3px;" class="btn btn-primary" v-on:click="addLine()"><i class="fa fa-pencil-square-o"></i>新增</a>
  54. </el-col>
  55. </el-row>
  56. <el-row :gutter="24">
  57. <el-col :span="2">
  58. </el-col>
  59. <el-col :span="22">
  60. <el-table ref="singleTable" highlight-current-row
  61. :data="dataSource4Detail"
  62. style="width: 100%"
  63. stripe border
  64. size="mini"
  65. height="500"
  66. v-on:current-change="handleCurrentChange">
  67. <el-table-column type="index" width="50"></el-table-column>
  68. <el-table-column prop="SetValueMin" label="批量下限" width="140">
  69. <template slot-scope="scope">
  70. <el-input-number v-model="scope.row.SetValueMin" controls-position="right" :min="0" size="small"></el-input-number>
  71. </template>
  72. </el-table-column>
  73. <el-table-column prop="SetValueMax" label="批量上限" width="140">
  74. <template slot-scope="scope">
  75. <el-input-number v-model="scope.row.SetValueMax" controls-position="right" :min="0" size="small"></el-input-number>
  76. </template>
  77. </el-table-column>
  78. <el-table-column prop="SampleQuantity" label="取样数量" width="140">
  79. <template slot-scope="scope">
  80. <el-input-number v-model="scope.row.SampleQuantity" controls-position="right" :min="0" size="small"></el-input-number>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="EATTRIBUTE1" label="允收数量" width="150">
  84. <template slot-scope="scope">
  85. <el-input-number v-model="scope.row.EATTRIBUTE1" controls-position="right" :min="0" size="small"></el-input-number>
  86. </template>
  87. </el-table-column>
  88. @*<el-table-column prop="EATTRIBUTE2" label="允许不良数(主要)" width="150">
  89. <template slot-scope="scope">
  90. <el-input-number v-model="scope.row.EATTRIBUTE2" controls-position="right" :min="0" size="small"></el-input-number>
  91. </template>
  92. </el-table-column>
  93. <el-table-column prop="EATTRIBUTE3" label="允许不良数(次要)" width="150">
  94. <template slot-scope="scope">
  95. <el-input-number v-model="scope.row.EATTRIBUTE3" controls-position="right" :min="0" size="small"></el-input-number>
  96. </template>
  97. </el-table-column>*@
  98. <el-table-column label="操作">
  99. <template slot-scope="scope">
  100. <a id="NF-Delete" authorize="yes" class="btn btn-primary" v-on:click="handleDelete(scope.$index, scope.row)"><i class="fa fa-trash-o"></i>删除</a>
  101. @*<el-button size="mini" type="danger" v-on:click="handleDelete(scope.$index, scope.row)">删除</el-button>*@
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. </el-col>
  106. <el-col :span="2">
  107. &nbsp; &nbsp;
  108. </el-col>
  109. </el-row>
  110. </el-form>
  111. </template>
  112. </div>
  113. </form>
  114. <script type="text/javascript">
  115. //const { Console } = require("node:console");
  116. var vm = new Vue({
  117. el: '#app',
  118. data: {
  119. id:'',
  120. userCode: "",
  121. ssList: [],
  122. form: {},
  123. detail: {
  124. key:0,
  125. SetValueMin: 0,
  126. SetValueMax: 0,
  127. SampleQuantity: 0,
  128. EATTRIBUTE1: 0,
  129. EATTRIBUTE2: 0,
  130. EATTRIBUTE3: 0,
  131. },
  132. dataSource4Detail: [],
  133. currentRow: null,
  134. rules: {
  135. RulesCode: [{ required: true, message: '请输入', trigger: 'blur' },],
  136. RulesName: [{ required: true, message: '请输入', trigger: 'blur' },],
  137. },
  138. disabled4RulesCode:false,
  139. },
  140. //挂在DOM 触发
  141. mounted() {
  142. let reactiveObject = {
  143. RulesCode: '',
  144. RulesName: '',
  145. RulesDesc: '',
  146. Type: '',
  147. Enable: true,
  148. DetailList: [],
  149. };
  150. this.form = reactiveObject;
  151. // this.loadGrid();
  152. // this.show();
  153. this.id = '@ViewData["ids"]';
  154. this.initControl();
  155. // console.log(this.id);
  156. },
  157. beforeDestroy() {
  158. // this.autoScrol1(true);
  159. },
  160. methods: {
  161. initControl: function () {
  162. let that = this;
  163. let orgName = '';
  164. this.disabled4RulesCode = this.id ? true : false;
  165. let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName';
  166. // console.log(userName);
  167. this.getData();
  168. },
  169. getData() {
  170. if (!this.id) return;
  171. axios
  172. .get('/BBWMS/IQCQuality/GetAql?keyValue=' + this.id)
  173. .then(function (res) {
  174. // console.log(res.data);
  175. //this.ssList = res.data;
  176. //if (res.data != null) {
  177. // res.data.forEach(function (el, i) {
  178. // Vue.set(vm.ssList, i, el)
  179. // });
  180. //}
  181. debugger;
  182. if (res.data) {
  183. for (var i in res.data) {
  184. Vue.set(vm.form, i, res.data[i]);
  185. }
  186. res.data.DetailList.forEach(function (el, i) {
  187. Vue.set(vm.dataSource4Detail, i, el)
  188. });
  189. }
  190. })
  191. .catch(function (error) { // 请求失败处理
  192. alert(error);
  193. });
  194. },
  195. addLine() {
  196. //debugger;
  197. // console.log('new line');
  198. let key = 1;
  199. let maxObj = this.dataSource4Detail.sort((a, b) => b.key - a.key)[0];
  200. if (maxObj != null) {
  201. key = maxObj.key + 1;
  202. }
  203. let obj = {
  204. key: key,
  205. SetValueMin: 0,
  206. SetValueMax: 0,
  207. SampleQuantity: 0,
  208. EATTRIBUTE1: '',
  209. EATTRIBUTE2: '',
  210. EATTRIBUTE3: '',
  211. };
  212. this.dataSource4Detail.push(obj );
  213. },
  214. //删除行
  215. handleDelete(index, row) {
  216. // console.log(index, row);
  217. this.dataSource4Detail = this.dataSource4Detail.filter(x => x.key != row.key);
  218. },
  219. //选中行变化
  220. handleCurrentChange(val) {
  221. this.currentRow = val;
  222. // console.log(val);
  223. },
  224. submitCheck() {
  225. // debugger;
  226. this.dataSource4Detail = this.dataSource4Detail.sort((a, b) => a.SetValueMin - b.SetValueMin);
  227. if (this.dataSource4Detail.length == 0) {
  228. $.modalMsg("必须存在规则信息行", "warning");
  229. return false;
  230. }
  231. let allNum = [];
  232. //debugger;
  233. for (var i = 0; i < this.dataSource4Detail.length; i++) {
  234. let item = this.dataSource4Detail[i];
  235. if (item.SetValueMin >= item.SetValueMax) {
  236. $.modalMsg("下限必须小于上限,行号 "+(i+1), "warning");
  237. return false;
  238. }
  239. allNum.push(item.SetValueMin);
  240. allNum.push(item.SetValueMax);
  241. }
  242. for (var i = 0; i < allNum.length; i++) {
  243. if (i == 0) {
  244. continue;
  245. }
  246. if (i <= allNum.length - 1) {
  247. if (allNum[i - 1] >= allNum[i]) {
  248. $.modalMsg("区间范围重复,重复值: " + allNum[i - 1], "warning");
  249. return false;
  250. }
  251. }
  252. }
  253. this.form.DetailList = this.dataSource4Detail;
  254. this.$refs['form'].validate((valid) => {
  255. if (valid) {
  256. //alert('submit!');
  257. $.submitForm({
  258. url: "/BBWMS/IQCQuality/SaveAql",
  259. param: { keyValue: JSON.stringify(this.form) },
  260. success: function () {
  261. $.currentWindow().$("#gridList").trigger("reloadGrid");
  262. }
  263. })
  264. } else {
  265. console.log('error submit!!');
  266. return false;
  267. }
  268. });
  269. // console.log(result);
  270. },
  271. },
  272. });
  273. function submitForm() {
  274. //debugger;
  275. vm.submitCheck();
  276. //if (!$('#form1').formValid()) {
  277. // $.modalMsg("验证未通过", "warning");
  278. // return false;
  279. //}
  280. //let obj = {
  281. // CheckFixtureNo: $("#F_CheckFixtureNo").val(),
  282. // CheckFixtureName: $("#F_CheckFixtureName").val(),
  283. // CustomerItemCode: $("#F_CustomerItemCode").val(),
  284. // ID: $("#ids").val(),
  285. // Useage: $("#F_Useage").val(),
  286. // Unit: $("#F_Unit").val(),
  287. // Remark: $("#F_Remark").val(),
  288. // Std: $("#F_Std").val(),
  289. //};
  290. ////if (!obj.line) {
  291. //// return false;
  292. ////}
  293. //if (!obj.CheckFixtureNo) {
  294. // return false;
  295. //}
  296. //$.submitForm({
  297. // url: "/BBWMS/CheckingFixture/SaveCheckingFixture",
  298. // param: { keyValue: JSON.stringify(obj) },
  299. // success: function () {
  300. // $.currentWindow().$("#gridList").trigger("reloadGrid");
  301. // }
  302. //})
  303. }
  304. </script>