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.

220 lines
8.3 KiB

3 weeks ago
  1. @{
  2. ViewBag.Title = "不良现象编辑";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  6. <!--引入 element-ui 的样式,-->
  7. <link rel="stylesheet" href="~/Content/element-ui/lib/theme-chalk/index.css">
  8. <script src="~/Content/vue/dist/vue.js"></script>
  9. <script src="~/Content/element-ui/lib/index.js"></script>
  10. <script src="~/Content/axios.min.js"></script>
  11. <style>
  12. </style>
  13. <form id="form1">
  14. <div id="app">
  15. <template>
  16. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  17. <el-divider>主表信息</el-divider>
  18. <el-row :gutter="24">
  19. <el-col :span="6">
  20. <el-form-item label="不良现象组编码" prop="BRGCode">
  21. <el-input v-model="form.BRGCode" placeholder="请输入内容" size="mini" :disabled="disabled4RulesCode"></el-input>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="6">
  25. <el-form-item label="不良现象组描述" prop="BRGDesc">
  26. <el-input v-model="form.BRGDesc" placeholder="请输入内容" size="mini"></el-input>
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. <el-divider>子表信息</el-divider>
  31. <el-row :gutter="24">
  32. <el-col :span="24">
  33. <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>
  34. </el-col>
  35. </el-row>
  36. <el-row :gutter="24">
  37. <el-col :span="2">
  38. </el-col>
  39. <el-col :span="20">
  40. <el-table ref="singleTable" highlight-current-row
  41. :data="dataSource4Detail"
  42. style="width: 100%"
  43. stripe border
  44. size="mini"
  45. v-on:current-change="handleCurrentChange">
  46. <el-table-column type="index" width="50"></el-table-column>
  47. <el-table-column prop="BadReasonCode" label="不良现象代码" width="140">
  48. <template slot-scope="scope">
  49. <el-input v-model="scope.row.BadReasonCode" size="small" :disabled="disabled4RulesCode"></el-input>
  50. </template>
  51. </el-table-column>
  52. <el-table-column prop="BadReasonDesc" label="不良现象描述" width="140">
  53. <template slot-scope="scope">
  54. <el-input v-model="scope.row.BadReasonDesc" size="small"></el-input>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="操作">
  58. <template slot-scope="scope">
  59. <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>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. </el-col>
  64. <el-col :span="2">
  65. &nbsp; &nbsp;
  66. </el-col>
  67. </el-row>
  68. </el-form>
  69. </template>
  70. </div>
  71. </form>
  72. <script type="text/javascript">
  73. //const { Console } = require("node:console");
  74. var vm = new Vue({
  75. el: '#app',
  76. data: {
  77. id:'',
  78. userCode: "",
  79. form: {},
  80. detail: {
  81. key:0,
  82. BadReasonCode: '',
  83. BadReasonDesc: '',
  84. },
  85. dataSource4Detail: [],
  86. currentRow: null,
  87. rules: {
  88. BRGCode: [{ required: true, message: '请输入', trigger: 'blur' },],
  89. BRGDesc: [{ required: true, message: '请输入', trigger: 'blur' },],
  90. },
  91. disabled4RulesCode:false,
  92. },
  93. //挂在DOM 触发
  94. mounted() {
  95. let reactiveObject = {
  96. BRGCode: '',
  97. BCGName: '',
  98. DetailList: [],
  99. };
  100. this.form = reactiveObject;
  101. // this.loadGrid();
  102. // this.show();
  103. this.id = '@ViewData["ids"]';
  104. this.initControl();
  105. // console.log(this.id);
  106. },
  107. beforeDestroy() {
  108. // this.autoScrol1(true);
  109. },
  110. methods: {
  111. initControl: function () {
  112. let that = this;
  113. let orgName = '';
  114. this.disabled4RulesCode = this.id ? true : false;
  115. let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName';
  116. // console.log(userName);
  117. this.getData();
  118. },
  119. getData() {
  120. if (!this.id) return;
  121. axios
  122. .get('/BBWMS/IQCQuality/GetBadReasonGroup?keyValue=' + this.id)
  123. .then(function (res) {
  124. if (res.data) {
  125. for (var i in res.data) {
  126. Vue.set(vm.form, i, res.data[i]);
  127. }
  128. res.data.DetailList.forEach(function (el, i) {
  129. Vue.set(vm.dataSource4Detail, i, el)
  130. });
  131. }
  132. })
  133. .catch(function (error) { // 请求失败处理
  134. alert(error);
  135. });
  136. },
  137. addLine() {
  138. //debugger;
  139. // console.log('new line');
  140. let key = 1;
  141. let maxObj = this.dataSource4Detail.sort((a, b) => b.key - a.key)[0];
  142. if (maxObj != null) {
  143. key = maxObj.key + 1;
  144. }
  145. let obj = {
  146. key: key,
  147. BadReasonCode: '',
  148. BadReasonDesc: '',
  149. };
  150. this.dataSource4Detail.push(obj );
  151. },
  152. //删除行
  153. handleDelete(index, row) {
  154. // console.log(index, row);
  155. this.dataSource4Detail = this.dataSource4Detail.filter(x => x.key != row.key);
  156. },
  157. //选中行变化
  158. handleCurrentChange(val) {
  159. this.currentRow = val;
  160. // console.log(val);
  161. },
  162. submitCheck() {
  163. // debugger;
  164. if (this.dataSource4Detail.length == 0) {
  165. $.modalMsg("必须存在不良现象行", "warning");
  166. return false;
  167. }
  168. for (var i = 0; i < this.dataSource4Detail.length; i++) {
  169. let detail = this.dataSource4Detail[i];
  170. if (!detail.BadReasonCode || !detail.BadReasonDesc ) {
  171. $.modalMsg("不良现象代码名称必填,行号 " + (i + 1), "warning");
  172. return false;
  173. }
  174. }
  175. this.form.DetailList = this.dataSource4Detail;
  176. this.$refs['form'].validate((valid) => {
  177. if (valid) {
  178. //alert('submit!');
  179. $.submitForm({
  180. url: "/BBWMS/IQCQuality/SaveBadReasonGroup",
  181. param: { keyValue: JSON.stringify(this.form) },
  182. success: function () {
  183. $.currentWindow().$("#gridList").trigger("reloadGrid");
  184. }
  185. })
  186. } else {
  187. console.log('error submit!!');
  188. return false;
  189. }
  190. });
  191. // console.log(result);
  192. },
  193. },
  194. });
  195. function submitForm() {
  196. //debugger;
  197. vm.submitCheck();
  198. }
  199. </script>