edit.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <div>
  3. <Toptitle :title="$route.query.type==1?'码单编辑':$route.query.type == 2?'码单查看':'码单新增'">
  4. <slot name="titleButton" class="btn_set">
  5. <div class="btn_set">
  6. <!-- <Upload
  7. :headers="headers"
  8. multiple
  9. name="your_file"
  10. :data="uploadData"
  11. :show-upload-list="false"
  12. :on-error="uploadError"
  13. :on-success="uploadSuccess"
  14. :before-upload="handleBeforeUpload"
  15. :action="$store.state.ip + '/api/cut_order_import'"
  16. style="margin-right: 10px"
  17. v-if="$route.query.type != 2"
  18. >
  19. <Button style="margin-left:10px" type="primary">导入</Button>
  20. </Upload> -->
  21. <div class="inputWrap" v-if="$route.query.type != 2">
  22. <button class="inputWrapButton"
  23. @click="onClickBtn">导入</button>
  24. <input type="file"
  25. multiple
  26. @change="onChange"
  27. ref='file'
  28. id="inputmultiple" />
  29. </div>
  30. <Button style="margin-left:10px" @click="$router.go(-1)">返回</Button>
  31. <Button style="margin-left:10px" v-if="$route.query.type != 2" @click="saveData">保存</Button>
  32. </div>
  33. </slot>
  34. </Toptitle>
  35. <div class="weight_memo_info_content">
  36. <div class="form_content">
  37. <Form :label-width="85" :model="formData">
  38. <FormItem label="项目编码:">
  39. <span v-if="this.$route.query.type == 2">{{formData.project_number}}</span>
  40. <Input size='small' v-model="formData.project_number" v-else placeholder="请输入项目编码"/>
  41. </FormItem>
  42. <FormItem label="项目名称:">
  43. <span v-if="this.$route.query.type == 2">{{formData.product_name}}</span>
  44. <Input v-else size='small' v-model='formData.product_name' placeholder="请输入项目名称"/>
  45. </FormItem>
  46. <FormItem label="项目简称:">
  47. <span v-if="this.$route.query.type == 2">{{formData.project_abbreviation}}</span>
  48. <Input v-else size='small' v-model="formData.project_abbreviation" placeholder="请输入项目简称"/>
  49. </FormItem>
  50. <FormItem label="下单日期:">
  51. <span v-if="this.$route.query.type == 2">{{formData.start_time}}</span>
  52. <DatePicker
  53. type="date"
  54. v-model="formData.start_time"
  55. placeholder="年/月/日"
  56. v-else
  57. size='small'
  58. ></DatePicker>
  59. </FormItem>
  60. </Form>
  61. </div>
  62. <Card v-for="(item,index) in infoNumber" :key="index">
  63. <div class="table_header">
  64. <div class="table_header_left">
  65. <span>图号:{{item.url_number}}</span>
  66. <span>产品名称:{{item.product_title}}</span>
  67. <span>批量数:{{item.number}}</span>
  68. <span>区域:{{item.region}}</span>
  69. <span :style="item.state == 1?'':'color:red;'"
  70. v-if="$route.query.type != 3"
  71. >{{item.state == 0?'未匹配':item.state == 2?'匹配完成':'匹配中'}}</span>
  72. </div>
  73. <div class="table_header_right">
  74. <Button type="primary" size="small" :disabled="item.state==0?false:true" @click="del(item,index)" v-if="$route.query.type!=2">删除</Button>
  75. <div @click="show(item,index)" style="cursor: pointer;"><span style="font-size:16px;">{{item.showType?'收缩':'展开'}}</span><Icon type="md-arrow-dropright" ref="ico" class="ico"/></div>
  76. <span>总计{{item.total}}条数据</span>
  77. </div>
  78. </div>
  79. <div v-if="item.showType">
  80. <div>
  81. <Topsearch :list="list" @searchData="search_data" />
  82. </div>
  83. <div v-for="(_item,_index) in tableData" :key="_index">
  84. <div class="mate_info">
  85. <div>匹配信息:{{_item.value}} {{_item.number}}组</div>
  86. <div>
  87. <span>总计{{_item.children.length}}条数据</span>
  88. <span style="margin:0 30px;cursor: pointer;" @click="showDetail(_item,_index)">{{_item.ishidden?'收缩':'展开'}}<Icon type="md-arrow-dropright" ref="ico" class="ico_detail"/></span>
  89. </div>
  90. </div>
  91. <Table :columns="tableColumns" border :data="_item.children" max-height="450" v-if='_item.ishidden'>
  92. <template slot="state" slot-scope="{row}">
  93. <span>{{row.state ==0?'未匹配':row.state ==2?'匹配完成':'匹配中'}}</span>
  94. </template>
  95. </Table>
  96. </div>
  97. </div>
  98. </Card>
  99. </div>
  100. </div>
  101. </template>
  102. <script>
  103. import axios from "axios";
  104. export default {
  105. data() {
  106. return {
  107. formData: {
  108. start_time: null,
  109. project_number:'',
  110. project_abbreviation:'',
  111. product_name:'',
  112. id:''
  113. },
  114. tableData:[],
  115. del_id:[],
  116. searchData: {},
  117. tableColumns:[
  118. { title: "序号", type:'index', align: "center", minWidth: 140 },
  119. { title: "部件名称", key: "part_title", align: "center", minWidth: 140 },
  120. { title: "行号", key: "line_number", align: "center", minWidth: 140 },
  121. { title: "木皮1", key: "veneer_one", align: "center", minWidth: 140 },
  122. { title: "原材料1", key: "board1", align: "center", minWidth: 140 },
  123. { title: "原材料2", key: "board2", align: "center", minWidth: 140 },
  124. { title: "木皮2", key: "veneer_two", align: "center", minWidth: 140 },
  125. { title: "毛料尺寸", key: "wollens_size", align: "center", minWidth: 140 },
  126. { title: "毛料合并的行号", key: "wool_line", align: "center", minWidth: 140 },
  127. { title: "原料数量", key: "material_num", align: "center", minWidth: 140 },
  128. { title: "精裁尺寸", key: "vacuum_size", align: "center", minWidth: 140 },
  129. { title: "零部件数量", key: "part_num", align: "center", minWidth: 140 },
  130. { title: "贴皮面积", key: "treatment_area", align: "center", minWidth: 140 },
  131. { title: "精裁面积", key: "vacuum_area", align: "center", minWidth: 140 },
  132. { title: "工艺要求", key: "technological_requirements", align: "center", minWidth: 140 },
  133. { title: "打印芯片", key: "chip_state", align: "center", minWidth: 140 },
  134. { title: "匹配状态", key: "state", align: "center", minWidth: 140,slot:'state' },
  135. ],
  136. headers: { Authorization: localStorage.getItem("token") },//请求头
  137. //进入页面需要获取的数值
  138. infoNumber:[],
  139. part_title:[],
  140. cut_size:[],
  141. cut_order_id:'',
  142. cut_order_product_id:''
  143. };
  144. },
  145. created(){
  146. if(this.$route.query.type == 1||this.$route.query.type == 2){
  147. this.axios.get('/api/cut_order_detail',{params:{cut_order_id:this.$route.query.cut_order_id,order_type:1}}).then(res=>{
  148. this.formData.project_number = res.data.project_number;
  149. this.formData.product_name = res.data.project_name;
  150. this.formData.project_abbreviation = res.data.abbreviation;
  151. this.formData.start_time = this.func.replaceDate(res.data.crt_time);
  152. this.infoNumber = [...res.data.children];
  153. console.log(this.infoNumber)
  154. this.cut_order_id = res.data.cut_order_id
  155. })
  156. }
  157. },
  158. mounted(){
  159. },
  160. computed: {
  161. list() {
  162. return [
  163. {
  164. title: "部件名称",
  165. name: "Select",
  166. value: "",
  167. filterable:true,
  168. multiple: true,
  169. placeholder: "请选择",
  170. serverName: "part_title",
  171. optionName:'part_title',
  172. optionValue:'part_title',
  173. option: [
  174. ...this.part_title
  175. ]
  176. },
  177. {
  178. title: "精裁尺寸",
  179. name: "Select",
  180. value: "",
  181. placeholder: "请选择",
  182. filterable:true,
  183. serverName: "cut_size",
  184. optionName:'cut_size',
  185. optionValue:'cut_size',
  186. option: [
  187. ...this.cut_size
  188. ]
  189. },
  190. {
  191. title: "匹配状态",
  192. name: "Select",
  193. value: "",
  194. placeholder: "请选择",
  195. serverName: "state",
  196. option: [
  197. { label: "匹配中", value: 1 },
  198. { label: "未匹配", value: 0 },
  199. { label: "匹配完成", value: 2 },
  200. ]
  201. }
  202. ];
  203. },
  204. uploadData(){
  205. return {type:this.infoNumber.length==0?this.$route.query.type:4,
  206. project_number:this.formData.project_number}
  207. },
  208. },
  209. methods: {
  210. showDetail(row,index){
  211. if(row.ishidden){
  212. document.getElementsByClassName('ico_detail')[index].style.transform = 'rotate(0deg)'
  213. row.ishidden = false
  214. this.$forceUpdate()
  215. }else{
  216. document.getElementsByClassName('ico_detail')[index].style.transform = 'rotate(90deg)'
  217. row.ishidden = true
  218. this.$forceUpdate();
  219. }
  220. },
  221. saveData(){
  222. if(!this.formData.project_number){
  223. this.$Message.warning('请填写项目编码!')
  224. }else{
  225. let date = new Date();
  226. if(!this.formData.start_time){
  227. this.formData.start_time = date
  228. }
  229. this.axios.get('/api/cut_order_save',{params:{
  230. project_name:this.formData.product_name,
  231. project_number:this.formData.project_number,
  232. abbreviation:this.formData.project_abbreviation,
  233. crt_time:this.formData.start_time,
  234. id:this.cut_order_id,
  235. }}).then(res=>{
  236. if(res.code ==200){
  237. this.$Message.success(res.msg)
  238. this.axios.post('/api/cut_order_del',{cut_order_product_id:this.del_id,order_type:1,cut_order_id:this.cut_order_id})
  239. }
  240. });
  241. }
  242. },
  243. search_data(row){
  244. this.axios.post('/api/cut_order_open',{
  245. cut_order_product_id:this.cut_order_product_id,
  246. cut_order_id:this.cut_order_id,
  247. order_type:1,
  248. ...row
  249. }).then(res=>{
  250. this.tableData=res.data.data;
  251. this.tableData.forEach(v=>{
  252. v.ishidden = fasle;
  253. })
  254. })
  255. },
  256. search(item){
  257. this.axios.post('/api/cut_order_open',{
  258. cut_order_product_id:item.cut_order_product_id,
  259. cut_order_id:this.cut_order_id,
  260. order_type:1
  261. }).then(res=>{
  262. this.tableData=res.data.data;
  263. this.tableData.forEach(v=>{
  264. v.ishidden=false
  265. })
  266. console.log(this.tableData)
  267. this.part_title = res.data.part_title;
  268. this.cut_size = res.data.cut_size;
  269. })
  270. },
  271. del(item,index){
  272. this.confirmDelete({
  273. content:'是否删除?',
  274. title:'码单删除',
  275. type:'primary',
  276. then:()=>{
  277. this.infoNumber.splice(index,1)
  278. this.del_id.push(item.cut_order_product_id)
  279. },
  280. cancel:()=>{}
  281. })
  282. },
  283. initData() {
  284. },
  285. handleBeforeUpload(row) {
  286. },
  287. uploadError(err) {
  288. this.$Message.error(err.msg || "导入失败");
  289. },
  290. uploadSuccess(res) {
  291. if (res.code == 200) {
  292. this.$Message.success("导入成功");
  293. this.cut_order_id = res.data.cut_order_id;
  294. this.formData.project_number = res.data.project_number;
  295. this.formData.product_name = res.data.project_name;
  296. this.formData.project_abbreviation = res.data.abbreviation;
  297. this.formData.id = res.data.cut_order_id;
  298. this.formData.start_time =this.func.replaceDate(res.data.crt_time);
  299. console.log(this.formData.start_time)
  300. if(this.infoNumber.length == 0){
  301. this.infoNumber.push(res.data.children)
  302. this.infoNumber[0].showType = false
  303. }else{
  304. this.infoNumber.push(res.data.children);
  305. this.infoNumber.forEach((item,index)=>{
  306. if(item.cut_order_product_id == res.data.children.cut_order_product_id){
  307. this.infoNumber.pop();
  308. this.infoNumber.splice(index,1,res.data.children)
  309. }
  310. })}
  311. } else {
  312. this.$Message.warning(res.msg || "导入失败");
  313. }
  314. },
  315. show(item,index) {
  316. // item.showType = !item.showType
  317. this.infoNumber[index].showType = !this.infoNumber[index].showType
  318. if(item.showType){ //全部未展开
  319. this.infoNumber.forEach(_item=>{
  320. _item.showType = false;
  321. })
  322. document.getElementsByClassName('ico')[index].style.transform = 'rotate(90deg)'
  323. item.showType = true
  324. this.$forceUpdate();
  325. this.cut_order_product_id = item.cut_order_product_id;
  326. this.search(item)
  327. }else{ //展开其中一项
  328. this.infoNumber.forEach(_item=>{
  329. _item.showType = false;
  330. })
  331. document.getElementsByClassName('ico')[index].style.transform = 'rotate(0deg)'
  332. this.tableData.forEach(v=>{
  333. v.ishidden = false;
  334. })
  335. this.$forceUpdate();
  336. }
  337. },
  338. repeatFile(){
  339. document.querySelector('#inputmultiple').setAttribute('type','text');
  340. document.querySelector('#inputmultiple').setAttribute('type','file');
  341. },
  342. async onChange (e) {
  343. let fileList =e.target.files;
  344. console.log(fileList)
  345. for (let i in fileList) {
  346. if (!isNaN(Number(i))) {
  347. this.headers["Content-Type"] = "application/x-www-form-urlencoded";
  348. let data = this.objToForm({
  349. ...this.uploadData,
  350. your_file: fileList[i],
  351. });
  352. await axios({
  353. url: this.$store.state.ip + '/api/cut_order_import',
  354. headers: this.headers,
  355. method: "post",
  356. data,
  357. }).then((res) => {
  358. console.log(res)
  359. this.repeatFile();
  360. if (res.data.code == 200) {
  361. this.$Message.success("导入成功");
  362. this.cut_order_id = res.data.data.cut_order_id;
  363. this.formData.project_number = res.data.data.project_number;
  364. this.formData.product_name = res.data.data.project_name;
  365. this.formData.project_abbreviation = res.data.data.abbreviation;
  366. this.formData.id = res.data.data.cut_order_id;
  367. this.formData.start_time =this.func.replaceDate(res.data.data.crt_time);
  368. console.log(this.formData.start_time)
  369. if(this.infoNumber.length == 0){
  370. this.infoNumber.push(res.data.data.children)
  371. this.infoNumber[0].showType = false
  372. }else{
  373. this.infoNumber.push(res.data.data.children);
  374. this.infoNumber.forEach((item,index)=>{
  375. if(item.cut_order_product_id == res.data.data.children.cut_order_product_id){
  376. this.infoNumber.pop();
  377. this.infoNumber.splice(index,1,res.data.data.children)
  378. }
  379. })}
  380. }else{
  381. this.$Message.error(res.data.msg)
  382. }
  383. })
  384. // await setTimeout(() => { }, 1000);
  385. }
  386. }
  387. },
  388. objToForm (obj) {
  389. let Form = new FormData();
  390. for (let i in obj) {
  391. Form.append(i, obj[i]);
  392. }
  393. return Form;
  394. },
  395. //点击事件
  396. onClickBtn () {
  397. this.$refs.file.click();
  398. }
  399. },
  400. };
  401. </script>
  402. <style scoped lang='scss'>
  403. .weight_memo_info_content{
  404. height: 700px;
  405. overflow: auto;
  406. }
  407. .form_content {
  408. margin-top: 10px;
  409. /deep/.ivu-form {
  410. display: flex;
  411. justify-content: flex-start;
  412. flex-wrap: wrap;
  413. }
  414. /deep/.ivu-form-item {
  415. display: inline-block;
  416. width: 250px;
  417. }
  418. }
  419. .table_header {
  420. display: flex;
  421. justify-content: space-between;
  422. .table_header_left{
  423. span{
  424. margin: 0 20px;
  425. }
  426. }
  427. .table_header_right {
  428. width: 240px;
  429. display: flex;
  430. justify-content: space-around;
  431. }
  432. }
  433. .mate_info{
  434. display: flex;
  435. justify-content: space-between;
  436. margin: 20px 0;
  437. }
  438. .ico{
  439. height:14px;
  440. transition: all 0.4s;
  441. vertical-align: middle;
  442. }
  443. /deep/ .ivu-card{
  444. border-radius: 15px;
  445. margin: 15px 0;
  446. background: rgb(236, 236, 236);
  447. }
  448. .btn_set{
  449. display: flex;
  450. }
  451. .inputWrap {
  452. position: relative;
  453. display: inline-block;
  454. }
  455. #inputmultiple {
  456. width: 100%;
  457. height: 100%;
  458. display: none;
  459. user-select: none;
  460. }
  461. .inputWrapButton {
  462. height: 32px;
  463. line-height: 32px;
  464. padding: 0 15px;
  465. user-select: none;
  466. border-radius: 4px;
  467. font-size: 14px;
  468. display: inline-block;
  469. color: #fff;
  470. background-color: #2d8cf0;
  471. border-color: #2d8cf0;
  472. outline: 0;
  473. border: none;
  474. cursor: pointer;
  475. transition: color 0.2s linear, background-color 0.2s linear,
  476. border 0.2s linear, box-shadow 0.2s linear;
  477. &:hover {
  478. background-color: #70b1f7;
  479. }
  480. }
  481. </style>