edit.vue 16 KB

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