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.

265 lines
11 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="120px">
  18. <el-divider>主表信息</el-divider>
  19. <el-row :gutter="24">
  20. <el-col :span="6">
  21. <el-form-item label="检验类型编码" prop="GroupCode">
  22. <el-input v-model="form.GroupCode" placeholder="请输入内容" size="mini" :disabled="disabled4RulesCode"></el-input>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="6">
  26. <el-form-item label="检验类型描述" prop="GroupName">
  27. <el-input v-model="form.GroupName" placeholder="请输入内容" size="mini"></el-input>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="检验属性" prop="EATTRIBUTE1">
  32. <el-input v-model="form.EATTRIBUTE1" placeholder="请输入内容" size="mini"></el-input>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="6">
  36. <el-form-item label="启用" prop="Enable">
  37. <el-switch v-model="form.Enable" active-color="#13ce66" inactive-color="#ff4949">
  38. </el-switch>
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. <el-divider>子表信息</el-divider>
  43. <el-row :gutter="24">
  44. <el-col :span="24">
  45. <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>
  46. </el-col>
  47. </el-row>
  48. <el-row :gutter="24">
  49. <el-col :span="2">
  50. </el-col>
  51. <el-col :span="20">
  52. <el-table ref="singleTable" highlight-current-row
  53. :data="dataSource4Detail"
  54. style="width: 100%"
  55. stripe border
  56. size="mini"
  57. v-on:current-change="handleCurrentChange">
  58. <el-table-column type="index" width="50"></el-table-column>
  59. <el-table-column prop="ListCode" label="检验项目代码" width="140">
  60. <template slot-scope="scope">
  61. <el-input v-model="scope.row.ListCode" size="small"></el-input>
  62. </template>
  63. </el-table-column>
  64. <el-table-column prop="ListName" label="检验项目名称" width="140">
  65. <template slot-scope="scope">
  66. <el-input v-model="scope.row.ListName" size="small"></el-input>
  67. </template>
  68. </el-table-column>
  69. <el-table-column prop="Unit" label="单位" width="140">
  70. <template slot-scope="scope">
  71. <el-input v-model="scope.row.Unit" size="small"></el-input>
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="SetValueMax" label="最大值" width="140">
  75. <template slot-scope="scope">
  76. <el-input v-model="scope.row.SetValueMax" size="small"></el-input>
  77. </template>
  78. </el-table-column>
  79. <el-table-column prop="SetValueMin" label="最小值" width="140">
  80. <template slot-scope="scope">
  81. <el-input v-model="scope.row.SetValueMin" size="small"></el-input>
  82. </template>
  83. </el-table-column>
  84. <el-table-column prop="Enable" label="启用" width="140">
  85. <template slot-scope="scope">
  86. <el-switch v-model="scope.row.Enable" active-color="#13ce66" inactive-color="#ff4949">
  87. </el-switch>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="操作">
  91. <template slot-scope="scope">
  92. <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>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. </el-col>
  97. <el-col :span="2">
  98. &nbsp; &nbsp;
  99. </el-col>
  100. </el-row>
  101. </el-form>
  102. </template>
  103. </div>
  104. </form>
  105. <script type="text/javascript">
  106. //const { Console } = require("node:console");
  107. var vm = new Vue({
  108. el: '#app',
  109. data: {
  110. id:'',
  111. userCode: "",
  112. form: {},
  113. detail: {
  114. key:0,
  115. BadCode: '',
  116. BadDesc: '',
  117. },
  118. dataSource4Detail: [],
  119. currentRow: null,
  120. rules: {
  121. GroupCode: [{ required: true, message: '请输入', trigger: 'blur' },],
  122. GroupName: [{ required: true, message: '请输入', trigger: 'blur' },],
  123. EATTRIBUTE1: [{ required: true, message: '请输入', trigger: 'blur' },],
  124. },
  125. disabled4RulesCode:false,
  126. },
  127. //挂在DOM 触发
  128. mounted() {
  129. let reactiveObject = {
  130. GroupCode: '',
  131. GroupName: '',
  132. Enable: true,
  133. EATTRIBUTE1:'',
  134. DetailList: [],
  135. };
  136. this.form = reactiveObject;
  137. // this.loadGrid();
  138. // this.show();
  139. this.id = '@ViewData["ids"]';
  140. this.initControl();
  141. // console.log(this.id);
  142. },
  143. beforeDestroy() {
  144. // this.autoScrol1(true);
  145. },
  146. methods: {
  147. initControl: function () {
  148. let that = this;
  149. let orgName = '';
  150. this.disabled4RulesCode = this.id ? true : false;
  151. let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName';
  152. // console.log(userName);
  153. this.getData();
  154. },
  155. getData() {
  156. if (!this.id) return;
  157. axios
  158. .get('/BBWMS/IQCQuality/GetCheckItemGroup?keyValue=' + this.id)
  159. .then(function (res) {
  160. if (res.data) {
  161. for (var i in res.data) {
  162. Vue.set(vm.form, i, res.data[i]);
  163. }
  164. res.data.DetailList.forEach(function (el, i) {
  165. Vue.set(vm.dataSource4Detail, i, el)
  166. });
  167. }
  168. })
  169. .catch(function (error) { // 请求失败处理
  170. alert(error);
  171. });
  172. },
  173. addLine() {
  174. //debugger;
  175. // console.log('new line');
  176. let key = 1;
  177. let maxObj = this.dataSource4Detail.sort((a, b) => b.key - a.key)[0];
  178. if (maxObj != null) {
  179. key = maxObj.key + 1;
  180. }
  181. let obj = {
  182. key: key,
  183. ListCode: '',
  184. ListName: '',
  185. Unit: '',
  186. SetValueMax: 0,
  187. SetValueMin: 0,
  188. Enable: true,
  189. };
  190. this.dataSource4Detail.push(obj );
  191. },
  192. //删除行
  193. handleDelete(index, row) {
  194. // console.log(index, row);
  195. this.dataSource4Detail = this.dataSource4Detail.filter(x => x.key != row.key);
  196. },
  197. //选中行变化
  198. handleCurrentChange(val) {
  199. this.currentRow = val;
  200. // console.log(val);
  201. },
  202. submitCheck() {
  203. // debugger;
  204. if (this.dataSource4Detail.length == 0) {
  205. $.modalMsg("必须存在检验项目行", "warning");
  206. return false;
  207. }
  208. for (var i = 0; i < this.dataSource4Detail.length; i++) {
  209. let detail = this.dataSource4Detail[i];
  210. if (!detail.ListCode || !detail.ListName ) {
  211. $.modalMsg("检验项目代码名称必填,行号 " + (i + 1), "warning");
  212. return false;
  213. }
  214. if (detail.SetValueMax <= 0 || detail.SetValueMin <= 0) {
  215. $.modalMsg("检验项目范围值必填,行号 " + (i + 1), "warning");
  216. return false;
  217. }
  218. if (detail.SetValueMax <= detail.SetValueMin) {
  219. $.modalMsg("最小值必须小于最大值,行号 " + (i + 1), "warning");
  220. return false;
  221. }
  222. }
  223. this.form.DetailList = this.dataSource4Detail;
  224. this.$refs['form'].validate((valid) => {
  225. if (valid) {
  226. //alert('submit!');
  227. $.submitForm({
  228. url: "/BBWMS/IQCQuality/SaveCheckItemGroup",
  229. param: { keyValue: JSON.stringify(this.form) },
  230. success: function () {
  231. $.currentWindow().$("#gridList").trigger("reloadGrid");
  232. }
  233. })
  234. } else {
  235. console.log('error submit!!');
  236. return false;
  237. }
  238. });
  239. // console.log(result);
  240. },
  241. },
  242. });
  243. function submitForm() {
  244. //debugger;
  245. vm.submitCheck();
  246. }
  247. </script>