edit.vue 16 KB

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