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.

397 lines
16 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" label-width="80px">
  18. <el-divider>搜索区域</el-divider>
  19. <el-row :gutter="24">
  20. <el-col :span="6">
  21. <el-form-item label="物料编码" prop="itemCode">
  22. <el-input v-model="itemCode" size="mini"></el-input>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="6">
  26. <el-form-item label="检验属性" prop="EATTRIBUTE1" >
  27. <el-select v-model="EATTRIBUTE1" placeholder="请选择" size="mini" v-on:change="change4EATTRIBUTE1">
  28. <el-option v-for="item in checkAttrList"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value">
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="6">
  37. </el-col>
  38. <el-col :span="6">
  39. <button id="btn_search" type="button" class="btn btn-primary" v-on:click="query()"><i class="fa fa-search"></i>查询物料</button>
  40. <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>
  41. </el-col>
  42. </el-row>
  43. <el-divider>选择区域</el-divider>
  44. <el-row :gutter="24">
  45. <el-col :span="24">
  46. <el-table ref="dataSource4Left" highlight-current-row
  47. :data="dataSource4Left"
  48. style="width: 100%"
  49. stripe border
  50. size="mini"
  51. height="200"
  52. v-on:current-change="handleCurrentChange">
  53. <el-table-column type="index" width="50"></el-table-column>
  54. <el-table-column prop="InvCode" label="料品编码" width="140">
  55. </el-table-column>
  56. <el-table-column prop="InvName" label="料品名称" width="140">
  57. </el-table-column>
  58. </el-table>
  59. </el-col>
  60. </el-row>
  61. <el-row :gutter="24">
  62. <el-col :span="24">
  63. <el-table ref="singleTable" highlight-current-row
  64. :data="dataSource4Detail"
  65. style="width: 100%"
  66. stripe border
  67. size="mini">
  68. <el-table-column type="index" width="50"></el-table-column>
  69. <el-table-column prop="ListCode" label="检验项目代码" width="140">
  70. <template slot-scope="scope">
  71. <el-input v-model="scope.row.ListCode" size="small"></el-input>
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="ListName" label="检验项目名称" width="140">
  75. <template slot-scope="scope">
  76. <el-input v-model="scope.row.ListName" size="small"></el-input>
  77. </template>
  78. </el-table-column>
  79. <el-table-column prop="EATTRIBUTE1" label="检验方法" width="140">
  80. <template slot-scope="scope">
  81. <el-input v-model="scope.row.EATTRIBUTE1" size="small"></el-input>
  82. </template>
  83. </el-table-column>
  84. <el-table-column prop="Unit" label="单位" width="140">
  85. <template slot-scope="scope">
  86. <el-input v-model="scope.row.Unit" size="small" :disabled="disabled4SetValue"></el-input>
  87. </template>
  88. </el-table-column>
  89. <el-table-column prop="SetValueMax" label="最大值" width="140">
  90. <template slot-scope="scope">
  91. <el-input-number v-model="scope.row.SetValueMax" controls-position="right" :min="0" size="small" :disabled="disabled4SetValue"></el-input-number>
  92. </template>
  93. </el-table-column>
  94. <el-table-column prop="SetValueMin" label="最小值" width="140">
  95. <template slot-scope="scope">
  96. <el-input-number v-model="scope.row.SetValueMin" controls-position="right" :min="0" size="small" :disabled="disabled4SetValue"></el-input-number>
  97. </template>
  98. </el-table-column>
  99. <el-table-column prop="Enable" label="启用" width="140">
  100. <template slot-scope="scope">
  101. <el-switch v-model="scope.row.Enable" active-color="#13ce66" inactive-color="#ff4949">
  102. </el-switch>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="操作">
  106. <template slot-scope="scope">
  107. <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>
  108. </template>
  109. </el-table-column>
  110. </el-table>
  111. </el-col>
  112. </el-row>
  113. </el-form>
  114. </template>
  115. </div>
  116. </form>
  117. <script type="text/javascript">
  118. //const { Console } = require("node:console");
  119. var vm = new Vue({
  120. el: '#app',
  121. data: {
  122. id:'',
  123. userCode: "",
  124. ssList: [],
  125. form: {},
  126. detail: {
  127. key:0,
  128. SetValueMin: 0,
  129. SetValueMax: 0,
  130. SampleQuantity: 0,
  131. EATTRIBUTE1: 0,
  132. EATTRIBUTE2: 0,
  133. EATTRIBUTE3: 0,
  134. },
  135. dataSource4Detail: [],//检验项目数据源
  136. rules: {
  137. RulesCode: [{ required: true, message: '请输入', trigger: 'blur' },],
  138. RulesName: [{ required: true, message: '请输入', trigger: 'blur' },],
  139. },
  140. disabled4RulesCode: false,
  141. disabled4SetValue: false,
  142. itemCode: '',
  143. //groupCode: '',
  144. dataSource4Left: [],//物料数据源
  145. checkAttrList: [],//
  146. item2CheckGroup: {
  147. EATTRIBUTE1:'',
  148. ItemList: [],
  149. CheckItemList:[],
  150. },
  151. selectItem4Item: null,
  152. EATTRIBUTE1:''//检验属性
  153. },
  154. //挂在DOM 触发
  155. mounted() {
  156. let reactiveObject = {
  157. RulesCode: '',
  158. RulesName: '',
  159. RulesDesc: '',
  160. Type: '',
  161. Enable: true,
  162. DetailList: [],
  163. };
  164. this.form = reactiveObject;
  165. // this.loadGrid();
  166. // this.show();
  167. this.id = '@ViewData["ids"]';
  168. this.initControl();
  169. this.getAllCheckAttr();
  170. // console.log(this.id);
  171. },
  172. beforeDestroy() {
  173. // this.autoScrol1(true);
  174. },
  175. methods: {
  176. change4EATTRIBUTE1(val) {
  177. // console.log(val);
  178. let currentSelect = this.checkAttrList.filter(x => x.value == val)[0];
  179. // console.log(currentSelect);
  180. if (currentSelect)
  181. this.disabled4SetValue = currentSelect.Ext1=="尺寸" ? false : true;
  182. else {
  183. this.disabled4SetValue = true;
  184. }
  185. },
  186. getAllCheckAttr() {
  187. axios
  188. .get('/BBWMS/IQCQuality/GetSelectItemList?keyValue=CheckAttr')
  189. .then(function (res) {
  190. //debugger;
  191. if (res.data) {
  192. res.data.forEach(function (el, i) {
  193. Vue.set(vm.checkAttrList, i, el)
  194. });
  195. }
  196. })
  197. .catch(function (error) { // 请求失败处理
  198. alert(error);
  199. });
  200. },
  201. addLine() {
  202. //debugger;
  203. // console.log('new line');
  204. let key = 1;
  205. let maxObj = this.dataSource4Detail.sort((a, b) => b.key - a.key)[0];
  206. if (maxObj != null) {
  207. key = maxObj.key + 1;
  208. }
  209. let obj = {
  210. key: key,
  211. ListCode: '',
  212. ListName: '',
  213. EATTRIBUTE1: '',
  214. Unit: '',
  215. SetValueMax: 0,
  216. SetValueMin: 0,
  217. Enable: true,
  218. };
  219. this.dataSource4Detail.push(obj);
  220. },
  221. //删除行
  222. handleDelete(index, row) {
  223. // console.log(index, row);
  224. this.dataSource4Detail = this.dataSource4Detail.filter(x => x.key != row.key);
  225. },
  226. initControl: function () {
  227. let that = this;
  228. let orgName = '';
  229. this.disabled4RulesCode = this.id ? true : false;
  230. let userName = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserName';
  231. // console.log(userName);
  232. this.getData();
  233. //this.getAllItem();
  234. //this.getAllAql();
  235. },
  236. getAllItem() {
  237. axios
  238. .get('/BBWMS/IQCQuality/GetAllItemList?code=' + this.itemCode.trim())
  239. .then(function (res) {
  240. //debugger;
  241. if (res.data) {
  242. res.data.forEach(function (el, i) {
  243. Vue.set(vm.dataSource4Left, i, el)
  244. });
  245. }
  246. })
  247. .catch(function (error) { // 请求失败处理
  248. alert(error);
  249. });
  250. },
  251. getAllCheckGroup() {
  252. //axios
  253. // .get('/BBWMS/IQCQuality/GetAllCheckGroupList?code=' + this.groupCode.trim())
  254. // .then(function (res) {
  255. // if (res.data) {
  256. // res.data.forEach(function (el, i) {
  257. // Vue.set(vm.dataSource4Right, i, el)
  258. // });
  259. // }
  260. // })
  261. // .catch(function (error) { // 请求失败处理
  262. // alert(error);
  263. // });
  264. },
  265. getData() {
  266. if (!this.id) return;
  267. axios
  268. .get('/BBWMS/IQCQuality/GetAql?keyValue=' + this.id)
  269. .then(function (res) {
  270. if (res.data) {
  271. for (var i in res.data) {
  272. Vue.set(vm.form, i, res.data[i]);
  273. }
  274. res.data.DetailList.forEach(function (el, i) {
  275. Vue.set(vm.dataSource4Detail, i, el)
  276. });
  277. }
  278. })
  279. .catch(function (error) { // 请求失败处理
  280. alert(error);
  281. });
  282. },
  283. query() {
  284. //debugger;
  285. this.itemCode = this.itemCode.trim();
  286. // this.groupCode = this.groupCode.trim();
  287. if (this.itemCode) {
  288. // this.dataSource4Left = this.dataSource4Left.filter(x => x.InvCode.includes(this.itemCode));
  289. this.getAllItem();
  290. }
  291. //if (this.groupCode) {
  292. // // this.dataSource4Right = this.dataSource4Right.filter(x => x.RulesCode.includes(this.groupCode));
  293. // this.getAllCheckGroup();
  294. //}
  295. },
  296. handleCurrentChange(val) {
  297. this.selectItem4Item = val;
  298. },
  299. submitCheck() {
  300. //console.log(this.multipleSelection);
  301. //console.log(this.currentRow4Right);
  302. debugger;
  303. if (this.dataSource4Detail.length == 0) {
  304. $.modalMsg("必须存在检验项目行", "warning");
  305. return false;
  306. }
  307. if (!this.selectItem4Item) {
  308. $.modalMsg("请选择物料行");
  309. return false;
  310. }
  311. if (!this.EATTRIBUTE1) {
  312. $.modalMsg("请选择检验属性");
  313. return false;
  314. }
  315. for (var i = 0; i < this.dataSource4Detail.length; i++) {
  316. let item = this.dataSource4Detail[i];
  317. if (this.EATTRIBUTE1 == "001") {
  318. if (!item.Unit || !item.SetValueMax || !item.SetValueMin) {
  319. $.modalMsg("当属性为尺寸时,最大值最小值单位必填,行号 " + (i + 1), "warning");
  320. return false;
  321. }
  322. if (item.SetValueMin >= item.SetValueMax) {
  323. $.modalMsg("下限必须小于上限,行号 " + (i + 1), "warning");
  324. return false;
  325. }
  326. }
  327. else {
  328. item.Unit = null;
  329. item.SetValueMax = null;
  330. item.SetValueMin = null;
  331. }
  332. item.InvCode = this.selectItem4Item.InvCode;
  333. item.InvName = this.selectItem4Item.InvName;
  334. item.CheckAttr = this.EATTRIBUTE1;
  335. }
  336. //this.item2CheckGroup.ItemList = [this.selectItem4Item];
  337. this.item2CheckGroup.CheckItemList = this.dataSource4Detail;
  338. //if (this.item2CheckGroup.ItemList.length != 1 || this.item2CheckGroup.CheckItemList.length == 0) {
  339. // $.modalMsg("必须选择物料行,检验类型行", "warning");
  340. // return false;
  341. //}
  342. this.$refs['form'].validate((valid) => {
  343. if (valid) {
  344. //alert('submit!');
  345. $.submitForm({
  346. url: "/BBWMS/IQCQuality/SaveItem2CheckItem",
  347. param: { keyValue: JSON.stringify(this.item2CheckGroup) },
  348. success: function () {
  349. $.currentWindow().$("#gridList").trigger("reloadGrid");
  350. }
  351. })
  352. } else {
  353. console.log('error submit!!');
  354. return false;
  355. }
  356. });
  357. // console.log(result);
  358. },
  359. },
  360. });
  361. function submitForm() {
  362. //debugger;
  363. vm.submitCheck();
  364. }
  365. </script>