edit.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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 />
  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'/>
  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"/>
  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)">删除</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: "material_num", align: "center", minWidth: 140 },
  107. { title: "精裁尺寸", key: "vacuum_size", align: "center", minWidth: 140 },
  108. { title: "零部件数量", key: "part_num", align: "center", minWidth: 140 },
  109. { title: "贴皮面积", key: "treatment_area", align: "center", minWidth: 140 },
  110. { title: "精裁面积", key: "vacuum_area", align: "center", minWidth: 140 },
  111. { title: "工艺要求", key: "technological_requirements", align: "center", minWidth: 140 },
  112. { title: "匹配状态", key: "match_state", align: "center", minWidth: 140,slot:'state' },
  113. ],
  114. headers: { Authorization: localStorage.getItem("token") },//请求头
  115. //进入页面需要获取的数值
  116. infoNumber:[],
  117. part_title:[],
  118. cut_size:[],
  119. cut_order_id:'',
  120. cut_order_product_id:''
  121. };
  122. },
  123. created(){
  124. if(this.$route.query.type == 1||this.$route.query.type == 2){
  125. this.axios.get('/api/cut_order_detail',{params:{cut_order_id:this.$route.query.cut_order_id,order_type:1}}).then(res=>{
  126. this.formData.project_number = res.data.project_number;
  127. this.formData.product_name = res.data.project_name;
  128. this.formData.project_abbreviation = res.data.abbreviation;
  129. this.formData.start_time = this.func.replaceDate(res.data.crt_time);
  130. this.infoNumber = [...res.data.children];
  131. console.log(this.infoNumber)
  132. this.cut_order_id = res.data.cut_order_id
  133. })
  134. }
  135. },
  136. mounted(){
  137. },
  138. computed: {
  139. list() {
  140. return [
  141. {
  142. title: "部件名称",
  143. name: "Select",
  144. value: "",
  145. multiple: true,
  146. placeholder: "请选择",
  147. serverName: "part_title",
  148. optionName:'part_title',
  149. optionValue:'part_title',
  150. option: [
  151. ...this.part_title
  152. ]
  153. },
  154. {
  155. title: "精裁尺寸",
  156. name: "Select",
  157. value: "",
  158. placeholder: "请选择",
  159. serverName: "cut_size",
  160. optionName:'cut_size',
  161. optionValue:'cut_size',
  162. option: [
  163. ...this.cut_size
  164. ]
  165. },
  166. {
  167. title: "匹配状态",
  168. name: "Select",
  169. value: "",
  170. placeholder: "请选择",
  171. serverName: "state",
  172. option: [
  173. { label: "匹配中", value: 1 },
  174. { label: "未匹配", value: 0 },
  175. { label: "匹配完成", value: 2 },
  176. ]
  177. }
  178. ];
  179. },
  180. uploadData(){
  181. return {type:this.infoNumber.length==0?this.$route.query.type:4,
  182. project_number:this.formData.project_number
  183. }
  184. },
  185. },
  186. methods: {
  187. saveData(){
  188. let date = new Date();
  189. if(!this.formData.start_time){
  190. this.formData.start_time = date
  191. }
  192. this.axios.get('/api/cut_order_save',{params:{
  193. project_name:this.formData.product_name,
  194. project_number:this.formData.project_number,
  195. abbreviation:this.formData.project_abbreviation,
  196. crt_time:this.formData.start_time,
  197. id:this.cut_order_id,
  198. }}).then(res=>{
  199. if(res.code ==200){
  200. this.$Message.success(res.msg)
  201. this.axios.post('/api/cut_order_del',{cut_order_product_id:this.del_id,order_type:1,cut_order_id:this.cut_order_id})
  202. }
  203. });
  204. },
  205. search_data(row){
  206. this.axios.post('/api/cut_order_open',{
  207. cut_order_product_id:this.cut_order_product_id,
  208. cut_order_id:this.cut_order_id,
  209. order_type:1,
  210. ...row
  211. }).then(res=>{
  212. this.tableData=res.data.data;
  213. })
  214. },
  215. search(item){
  216. this.axios.post('/api/cut_order_open',{
  217. cut_order_product_id:item.cut_order_product_id,
  218. cut_order_id:this.cut_order_id,
  219. order_type:1
  220. }).then(res=>{
  221. this.tableData=res.data.data;
  222. this.part_title = res.data.part_title;
  223. this.cut_size = res.data.cut_size;
  224. })
  225. },
  226. del(item,index){
  227. this.confirmDelete({
  228. content:'是否删除?',
  229. title:'码单删除',
  230. type:'primary',
  231. then:()=>{
  232. this.infoNumber.splice(index,1)
  233. this.del_id.push(item.cut_order_product_id)
  234. },
  235. cancel:()=>{}
  236. })
  237. },
  238. initData() {
  239. },
  240. handleBeforeUpload() {},
  241. uploadError(err) {
  242. this.$Message.error(err.msg || "导入失败");
  243. },
  244. uploadSuccess(res) {
  245. if (res.code == 200) {
  246. this.$Message.success("导入成功");
  247. this.cut_order_id = res.data.cut_order_id;
  248. this.formData.project_number = res.data.project_number;
  249. this.formData.product_name = res.data.project_name;
  250. this.formData.id = res.data.cut_order_id;
  251. this.formData.start_time =this.func.replaceDate(res.data.crt_time);
  252. console.log(this.formData.start_time)
  253. if(this.infoNumber.length == 0){
  254. this.infoNumber.push(res.data.children)
  255. this.infoNumber[0].showType = false
  256. }else{
  257. this.infoNumber.push(res.data.children);
  258. this.infoNumber.forEach((item,index)=>{
  259. if(item.cut_order_product_id == res.data.children.cut_order_product_id){
  260. this.infoNumber.pop();
  261. this.infoNumber.splice(index,1,res.data.children)
  262. }
  263. })}
  264. } else {
  265. this.$Message.warning(res.msg || "导入失败");
  266. }
  267. },
  268. show(item,index) {
  269. // item.showType = !item.showType
  270. this.infoNumber[index].showType = !this.infoNumber[index].showType
  271. if(item.showType){ //全部未展开
  272. this.infoNumber.forEach(_item=>{
  273. _item.showType = false;
  274. })
  275. document.getElementsByClassName('ico')[index].style.transform = 'rotate(90deg)'
  276. item.showType = true
  277. this.$forceUpdate();
  278. this.cut_order_product_id = item.cut_order_product_id;
  279. this.search(item)
  280. }else{ //展开其中一项
  281. this.infoNumber.forEach(_item=>{
  282. _item.showType = false;
  283. })
  284. document.getElementsByClassName('ico')[index].style.transform = 'rotate(0deg)'
  285. this.$forceUpdate();
  286. }
  287. },
  288. },
  289. };
  290. </script>
  291. <style scoped lang='scss'>
  292. .weight_memo_info_content{
  293. height: 700px;
  294. overflow: auto;
  295. }
  296. .form_content {
  297. margin-top: 10px;
  298. /deep/.ivu-form {
  299. display: flex;
  300. justify-content: flex-start;
  301. flex-wrap: wrap;
  302. }
  303. /deep/.ivu-form-item {
  304. display: inline-block;
  305. width: 250px;
  306. }
  307. }
  308. .table_header {
  309. display: flex;
  310. justify-content: space-between;
  311. .table_header_left{
  312. span{
  313. margin: 0 20px;
  314. }
  315. }
  316. .table_header_right {
  317. width: 240px;
  318. display: flex;
  319. justify-content: space-around;
  320. }
  321. }
  322. .mate_info{
  323. display: flex;
  324. justify-content: space-between;
  325. margin: 20px 0;
  326. }
  327. .ico{
  328. height:14px;
  329. transition: all 0.4s;
  330. vertical-align: middle;
  331. }
  332. /deep/ .ivu-card{
  333. border-radius: 15px;
  334. margin: 15px 0;
  335. background: rgb(236, 236, 236);
  336. }
  337. .btn_set{
  338. display: flex;
  339. }
  340. </style>