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.

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