edit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. name="your_file"
  9. :data="uploadData"
  10. :show-upload-list="false"
  11. :on-error="uploadError"
  12. :on-success="uploadSuccess"
  13. :before-upload="handleBeforeUpload"
  14. :action="$store.state.ip + '/api/cut_order_import'"
  15. style="margin-right: 10px"
  16. v-if="$route.query.type != 2"
  17. >
  18. <Button style="margin-left:10px" type="primary">导入</Button>
  19. </Upload>
  20. <Button style="margin-left:10px" @click="$router.go(-1)">返回</Button>
  21. <Button style="margin-left:10px" v-if="$route.query.type != 2" @click="saveData">保存</Button>
  22. </div>
  23. </slot>
  24. </Toptitle>
  25. <div class="weight_memo_info_content">
  26. <div class="form_content">
  27. <Form :label-width="85" :model="formData">
  28. <FormItem label="项目编码:">
  29. <span v-if="this.$route.query.type == 2">{{formData.project_number}}</span>
  30. <Input size='small' v-model="formData.project_number" v-else placeholder="请输入项目编码"/>
  31. </FormItem>
  32. <FormItem label="项目名称:">
  33. <span v-if="this.$route.query.type == 2">{{formData.product_name}}</span>
  34. <Input v-else size='small' v-model='formData.product_name' placeholder="请输入项目名称"/>
  35. </FormItem>
  36. <FormItem label="项目简称:">
  37. <span v-if="this.$route.query.type == 2">{{formData.project_abbreviation}}</span>
  38. <Input v-else size='small' v-model="formData.project_abbreviation" placeholder="请输入项目简称"/>
  39. </FormItem>
  40. <FormItem label="下单日期:">
  41. <span v-if="this.$route.query.type == 2">{{formData.start_time}}</span>
  42. <DatePicker
  43. type="date"
  44. v-model="formData.start_time"
  45. placeholder="年/月/日"
  46. v-else
  47. size='small'
  48. ></DatePicker>
  49. </FormItem>
  50. </Form>
  51. </div>
  52. <Card v-for="(item,index) in infoNumber" :key="index">
  53. <div class="table_header">
  54. <div class="table_header_left">
  55. <span>图号:{{item.url_number}}</span>
  56. <span>产品名称:{{item.product_title}}</span>
  57. <span :style="item.state == 1?'':'color:red;'"
  58. v-if="$route.query.type != 3"
  59. >{{item.state == 0?'未匹配':item.state == 1?'匹配完成':'匹配中'}}</span>
  60. </div>
  61. <div class="table_header_right">
  62. <Button type="primary" size="small" :disabled="item.state==0?false:true" @click="del(item,index)" v-if="$route.query.type!=2">删除</Button>
  63. <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>
  64. <span>总计{{item.total}}条数据</span>
  65. </div>
  66. </div>
  67. <div v-if="item.showType">
  68. <div>
  69. <Topsearch :list="list" @searchData="search_data" />
  70. </div>
  71. <div v-for="(_item,_index) in tableData" :key="_index">
  72. <div class="mate_info"><div>匹配信息:{{_item.value}} {{_item.number}}组</div><span>总计{{_item.children.length}}条数据</span></div>
  73. <Table :columns="tableColumns" border :data="_item.children">
  74. <template slot="state" slot-scope="{row}">
  75. <span>{{row.state ==0?'未匹配':row.state ==2?'匹配完成':'匹配中'}}</span>
  76. </template>
  77. </Table>
  78. </div>
  79. </div>
  80. </Card>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. export default {
  86. data() {
  87. return {
  88. formData: {
  89. start_time: null,
  90. project_number:'',
  91. project_abbreviation:'',
  92. product_name:'',
  93. id:''
  94. },
  95. tableData:[],
  96. del_id:[],
  97. searchData: {},
  98. tableColumns:[
  99. { title: "序号", type:'index', align: "center", minWidth: 140 },
  100. { title: "部件名称", key: "part_title", align: "center", minWidth: 140 },
  101. { title: "行号", key: "line_number", align: "center", minWidth: 140 },
  102. { title: "木皮1", key: "veneer_one", align: "center", minWidth: 140 },
  103. { title: "原材料", key: "material", align: "center", minWidth: 140 },
  104. { title: "木皮2", key: "veneer_two", align: "center", minWidth: 140 },
  105. { title: "毛料尺寸", key: "wollens_size", align: "center", minWidth: 140 },
  106. { title: "毛料合并的行号", key: "wool_line", align: "center", minWidth: 140 },
  107. { title: "原料数量", key: "material_num", align: "center", minWidth: 140 },
  108. { title: "精裁尺寸", key: "vacuum_size", align: "center", minWidth: 140 },
  109. { title: "零部件数量", key: "part_num", align: "center", minWidth: 140 },
  110. { title: "贴皮面积", key: "treatment_area", align: "center", minWidth: 140 },
  111. { title: "精裁面积", key: "vacuum_area", align: "center", minWidth: 140 },
  112. { title: "工艺要求", key: "technological_requirements", align: "center", minWidth: 140 },
  113. { title: "匹配状态", key: "state", align: "center", minWidth: 140,slot:'state' },
  114. ],
  115. headers: { Authorization: localStorage.getItem("token") },//请求头
  116. //进入页面需要获取的数值
  117. infoNumber:[],
  118. part_title:[],
  119. cut_size:[],
  120. cut_order_id:'',
  121. cut_order_product_id:''
  122. };
  123. },
  124. created(){
  125. if(this.$route.query.type == 1||this.$route.query.type == 2){
  126. this.axios.get('/api/cut_order_detail',{params:{cut_order_id:this.$route.query.cut_order_id,order_type:1}}).then(res=>{
  127. this.formData.project_number = res.data.project_number;
  128. this.formData.product_name = res.data.project_name;
  129. this.formData.project_abbreviation = res.data.abbreviation;
  130. this.formData.start_time = this.func.replaceDate(res.data.crt_time);
  131. this.infoNumber = [...res.data.children];
  132. console.log(this.infoNumber)
  133. this.cut_order_id = res.data.cut_order_id
  134. })
  135. }
  136. },
  137. mounted(){
  138. },
  139. computed: {
  140. list() {
  141. return [
  142. {
  143. title: "部件名称",
  144. name: "Select",
  145. value: "",
  146. multiple: true,
  147. placeholder: "请选择",
  148. serverName: "part_title",
  149. optionName:'part_title',
  150. optionValue:'part_title',
  151. option: [
  152. ...this.part_title
  153. ]
  154. },
  155. {
  156. title: "精裁尺寸",
  157. name: "Select",
  158. value: "",
  159. placeholder: "请选择",
  160. serverName: "cut_size",
  161. optionName:'cut_size',
  162. optionValue:'cut_size',
  163. option: [
  164. ...this.cut_size
  165. ]
  166. },
  167. {
  168. title: "匹配状态",
  169. name: "Select",
  170. value: "",
  171. placeholder: "请选择",
  172. serverName: "state",
  173. option: [
  174. { label: "匹配中", value: 1 },
  175. { label: "未匹配", value: 0 },
  176. { label: "匹配完成", value: 2 },
  177. ]
  178. }
  179. ];
  180. },
  181. uploadData(){
  182. return {type:this.infoNumber.length==0?this.$route.query.type:4,
  183. project_number:this.formData.project_number
  184. }
  185. },
  186. },
  187. methods: {
  188. saveData(){
  189. if(!this.formData.project_number){
  190. this.$Message.warning('请填写项目编码!')
  191. }else{
  192. let date = new Date();
  193. if(!this.formData.start_time){
  194. this.formData.start_time = date
  195. }
  196. this.axios.get('/api/cut_order_save',{params:{
  197. project_name:this.formData.product_name,
  198. project_number:this.formData.project_number,
  199. abbreviation:this.formData.project_abbreviation,
  200. crt_time:this.formData.start_time,
  201. id:this.cut_order_id,
  202. }}).then(res=>{
  203. if(res.code ==200){
  204. this.$Message.success(res.msg)
  205. this.axios.post('/api/cut_order_del',{cut_order_product_id:this.del_id,order_type:1,cut_order_id:this.cut_order_id})
  206. }
  207. });
  208. }
  209. },
  210. search_data(row){
  211. this.axios.post('/api/cut_order_open',{
  212. cut_order_product_id:this.cut_order_product_id,
  213. cut_order_id:this.cut_order_id,
  214. order_type:1,
  215. ...row
  216. }).then(res=>{
  217. this.tableData=res.data.data;
  218. })
  219. },
  220. search(item){
  221. this.axios.post('/api/cut_order_open',{
  222. cut_order_product_id:item.cut_order_product_id,
  223. cut_order_id:this.cut_order_id,
  224. order_type:1
  225. }).then(res=>{
  226. this.tableData=res.data.data;
  227. this.part_title = res.data.part_title;
  228. this.cut_size = res.data.cut_size;
  229. })
  230. },
  231. del(item,index){
  232. this.confirmDelete({
  233. content:'是否删除?',
  234. title:'码单删除',
  235. type:'primary',
  236. then:()=>{
  237. this.infoNumber.splice(index,1)
  238. this.del_id.push(item.cut_order_product_id)
  239. },
  240. cancel:()=>{}
  241. })
  242. },
  243. initData() {
  244. },
  245. handleBeforeUpload() {},
  246. uploadError(err) {
  247. this.$Message.error(err.msg || "导入失败");
  248. },
  249. uploadSuccess(res) {
  250. if (res.code == 200) {
  251. this.$Message.success("导入成功");
  252. this.cut_order_id = res.data.cut_order_id;
  253. this.formData.project_number = res.data.project_number;
  254. this.formData.product_name = res.data.project_name;
  255. this.formData.project_abbreviation = res.data.abbreviation;
  256. this.formData.id = res.data.cut_order_id;
  257. this.formData.start_time =this.func.replaceDate(res.data.crt_time);
  258. console.log(this.formData.start_time)
  259. if(this.infoNumber.length == 0){
  260. this.infoNumber.push(res.data.children)
  261. this.infoNumber[0].showType = false
  262. }else{
  263. this.infoNumber.push(res.data.children);
  264. this.infoNumber.forEach((item,index)=>{
  265. if(item.cut_order_product_id == res.data.children.cut_order_product_id){
  266. this.infoNumber.pop();
  267. this.infoNumber.splice(index,1,res.data.children)
  268. }
  269. })}
  270. } else {
  271. this.$Message.warning(res.msg || "导入失败");
  272. }
  273. },
  274. show(item,index) {
  275. // item.showType = !item.showType
  276. this.infoNumber[index].showType = !this.infoNumber[index].showType
  277. if(item.showType){ //全部未展开
  278. this.infoNumber.forEach(_item=>{
  279. _item.showType = false;
  280. })
  281. document.getElementsByClassName('ico')[index].style.transform = 'rotate(90deg)'
  282. item.showType = true
  283. this.$forceUpdate();
  284. this.cut_order_product_id = item.cut_order_product_id;
  285. this.search(item)
  286. }else{ //展开其中一项
  287. this.infoNumber.forEach(_item=>{
  288. _item.showType = false;
  289. })
  290. document.getElementsByClassName('ico')[index].style.transform = 'rotate(0deg)'
  291. this.$forceUpdate();
  292. }
  293. },
  294. },
  295. };
  296. </script>
  297. <style scoped lang='scss'>
  298. .weight_memo_info_content{
  299. height: 700px;
  300. overflow: auto;
  301. }
  302. .form_content {
  303. margin-top: 10px;
  304. /deep/.ivu-form {
  305. display: flex;
  306. justify-content: flex-start;
  307. flex-wrap: wrap;
  308. }
  309. /deep/.ivu-form-item {
  310. display: inline-block;
  311. width: 250px;
  312. }
  313. }
  314. .table_header {
  315. display: flex;
  316. justify-content: space-between;
  317. .table_header_left{
  318. span{
  319. margin: 0 20px;
  320. }
  321. }
  322. .table_header_right {
  323. width: 240px;
  324. display: flex;
  325. justify-content: space-around;
  326. }
  327. }
  328. .mate_info{
  329. display: flex;
  330. justify-content: space-between;
  331. margin: 20px 0;
  332. }
  333. .ico{
  334. height:14px;
  335. transition: all 0.4s;
  336. vertical-align: middle;
  337. }
  338. /deep/ .ivu-card{
  339. border-radius: 15px;
  340. margin: 15px 0;
  341. background: rgb(236, 236, 236);
  342. }
  343. .btn_set{
  344. display: flex;
  345. }
  346. </style>