edit.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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_room_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;'">{{item.state == 0?'未匹配':item.state == 1?'匹配完成':'匹配中'}}</span>
  58. </div>
  59. <div class="table_header_right">
  60. <Button type="primary" size="small" :disabled="item.state==0?false:true" @click="del(item,index)">删除</Button>
  61. <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>
  62. <span>总计{{item.total}}条数据</span>
  63. </div>
  64. </div>
  65. <div v-if="item.showType">
  66. <div>
  67. <Topsearch :list="list" @searchData="initData" />
  68. </div>
  69. <Table :columns="set_tableColumns" border :data="tableData">
  70. <template slot="match_state" slot-scope="{row}">
  71. <span>{{row.state == 0?'未匹配':row.state == 2?'匹配完成':'匹配中'}}</span>
  72. </template>
  73. </Table>
  74. </div>
  75. </Card>
  76. </div>
  77. </div>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. formData: {
  84. start_time: null,
  85. project_number:'',
  86. project_abbreviation:'',
  87. product_name:'',
  88. id:''
  89. },
  90. add_tableColumns:[],
  91. tableData:[],
  92. searchData: {},
  93. tableColumns:[
  94. { title: "序号", type:'index', align: "center", minWidth: 140 },
  95. { title: "区域", key: "region", align: "center", minWidth: 140 },
  96. { title: "楼栋", key: "house", align: "center", minWidth: 140 },
  97. { title: "单元", key: "unit", align: "center", minWidth: 140 },
  98. { title: "楼层", key: "layer", align: "center", minWidth: 140 },
  99. { title: "房间号", key: "number", align: "center", minWidth: 140 }
  100. ],
  101. showType: false,
  102. headers: { Authorization: localStorage.getItem("token") },//请求头
  103. //进入页面需要获取的数值
  104. infoNumber:[],
  105. cut_order_id:'',
  106. del_id:[],
  107. number:[],
  108. region:[],
  109. cut_order_product_id:'',
  110. };
  111. },
  112. created(){
  113. if(this.$route.query.type == 1||this.$route.query.type == 2){
  114. this.axios.get('/api/cut_order_detail',{params:{cut_order_id:this.$route.query.cut_order_id,order_type:2}}).then(res=>{
  115. this.formData.project_number = res.data.project_number;
  116. this.formData.product_name = res.data.project_name;
  117. this.formData.project_abbreviation = res.data.abbreviation;
  118. this.formData.start_time = this.func.replaceDate(res.data.crt_time);
  119. this.infoNumber = [...res.data.children];
  120. this.cut_order_id = res.data.cut_order_id
  121. })
  122. }
  123. },
  124. mounted(){
  125. },
  126. computed: {
  127. list() {
  128. return [
  129. {
  130. title: "区域名称",
  131. name: "Select",
  132. value: "",
  133. multiple: true,
  134. placeholder: "请选择",
  135. serverName: "region",
  136. optionName:'region',
  137. optionValue:'region',
  138. option: [
  139. ...this.region
  140. ]
  141. },
  142. {
  143. title: "房号",
  144. name: "Select",
  145. value: "",
  146. placeholder: "请选择",
  147. serverName: "number",
  148. optionName:'number',
  149. optionValue:'number',
  150. option: [
  151. ...this.number
  152. ]
  153. },
  154. {
  155. title: "匹配状态",
  156. name: "Select",
  157. value: "",
  158. placeholder: "请选择",
  159. serverName: "state",
  160. option: [
  161. { label: "匹配完成", value: 2 },
  162. { label: "未匹配", value: 0 },
  163. { label: "匹配中", value: 1 },
  164. ]
  165. }
  166. ];
  167. },
  168. uploadData(){
  169. return {type:this.infoNumber.length==0?this.$route.query.type:4}
  170. },
  171. set_tableColumns(){
  172. return [...this.tableColumns,
  173. ...this.add_tableColumns,
  174. { title: "匹配状态", key: "match_state", align: "center", minWidth: 140 ,slot:'match_state'}
  175. ]
  176. }
  177. },
  178. methods: {
  179. saveData(){
  180. let date = new Date();
  181. if(!this.formData.start_time){
  182. this.formData.start_time = date
  183. }
  184. this.axios.get('/api/cut_order_save',{params:{
  185. project_name:this.formData.product_name,
  186. project_number:this.formData.project_number,
  187. abbreviation:this.formData.project_abbreviation,
  188. crt_time:this.formData.start_time,
  189. id:this.cut_order_id,
  190. }}).then(res=>{
  191. if(res.code ==200){
  192. this.$Message.success(res.msg)
  193. this.axios.post('/api/cut_order_del',{cut_order_product_id:this.del_id,order_type:2,cut_order_id:this.cut_order_id})
  194. }
  195. });
  196. },
  197. search(item){
  198. this.add_tableColumns = [];
  199. this.axios.post('/api/cut_order_open',{
  200. cut_order_product_id:item.cut_order_product_id,
  201. cut_order_id:this.cut_order_id,
  202. order_type:2
  203. }).then(res=>{
  204. this.number = res.data.number;
  205. this.region = res.data.region;
  206. let obj ={
  207. title:'',
  208. key:'',
  209. align: "center",
  210. minWidth: 140
  211. };
  212. this.tableData=res.data.data;
  213. for(let i in this.tableData[0]){
  214. if(i.charAt(0) == 'W'){
  215. obj.title = i;
  216. obj.key = i;
  217. this.add_tableColumns.push(JSON.parse(JSON.stringify(obj)))
  218. }
  219. };
  220. this.$forceUpdate();
  221. })
  222. },
  223. del(item,index){
  224. this.confirmDelete({
  225. content:'是否删除?',
  226. title:'房间删除',
  227. type:'primary',
  228. then:()=>{
  229. this.infoNumber.splice(index,1);
  230. this.del_id.push(item.cut_order_product_id)
  231. },
  232. cancel:()=>{}
  233. })
  234. },
  235. initData(row) {
  236. this.add_tableColumns = [];
  237. this.axios.post('/api/cut_order_open',{
  238. cut_order_product_id:this.cut_order_product_id,
  239. cut_order_id:this.cut_order_id,
  240. order_type:2,
  241. ...row
  242. }).then(res=>{
  243. let obj ={
  244. title:'',
  245. key:'',
  246. align: "center",
  247. minWidth: 140
  248. };
  249. this.tableData=res.data.data;
  250. for(let i in this.tableData[0]){
  251. if(i.charAt(0) == 'W'){
  252. obj.title = i;
  253. obj.key = i;
  254. this.add_tableColumns.push(JSON.parse(JSON.stringify(obj)))
  255. }
  256. };
  257. this.$forceUpdate();
  258. })
  259. },
  260. handleBeforeUpload() {},
  261. uploadError(err) {
  262. this.$Message.error(err.msg || "导入失败");
  263. },
  264. uploadSuccess(res) {
  265. if (res.code == 200) {
  266. this.$Message.success("导入成功");
  267. this.cut_order_id = res.data.cut_order_id;
  268. this.formData.project_number = res.data.project_number;
  269. this.formData.product_name = res.data.project_name;
  270. this.formData.id = res.data.cut_order_id;
  271. this.formData.start_time =this.func.replaceDate(res.data.crt_time);
  272. if(this.infoNumber.length == 0){
  273. this.infoNumber.push(res.data.children)
  274. this.infoNumber[0].showType = false
  275. }else{
  276. this.infoNumber.push(res.data.children);
  277. this.infoNumber.forEach((item,index)=>{
  278. if(item.cut_order_product_id == res.data.children.cut_order_product_id){
  279. this.infoNumber.pop();
  280. this.infoNumber.splice(index,1,res.data.children)
  281. }
  282. })}
  283. } else {
  284. this.$Message.warning(res.msg || "导入失败");
  285. }
  286. },
  287. show(item,index) {
  288. item.showType = !item.showType
  289. if(item.showType){ //全部未展开
  290. this.infoNumber.forEach(_item=>{
  291. _item.showType = false;
  292. })
  293. document.getElementsByClassName('ico')[index].style.transform = 'rotate(90deg)'
  294. this.search(item);
  295. this.$forceUpdate();
  296. this.cut_order_product_id = item.cut_order_product_id;
  297. item.showType = true
  298. }else{ //展开其中一项
  299. this.infoNumber.forEach(_item=>{
  300. _item.showType = false;
  301. })
  302. document.getElementsByClassName('ico')[index].style.transform = 'rotate(0deg)';
  303. this.$forceUpdate();
  304. }
  305. },
  306. },
  307. };
  308. </script>
  309. <style scoped lang='scss'>
  310. .weight_memo_info_content{
  311. height: 700px;
  312. overflow: auto;
  313. }
  314. .form_content {
  315. margin-top: 10px;
  316. /deep/.ivu-form {
  317. display: flex;
  318. justify-content: flex-start;
  319. flex-wrap: wrap;
  320. }
  321. /deep/.ivu-form-item {
  322. display: inline-block;
  323. width: 250px;
  324. }
  325. }
  326. .table_header {
  327. display: flex;
  328. justify-content: space-between;
  329. .table_header_left{
  330. span{
  331. margin: 0 20px;
  332. }
  333. }
  334. .table_header_right {
  335. width: 240px;
  336. display: flex;
  337. justify-content: space-around;
  338. }
  339. }
  340. .mate_info{
  341. display: flex;
  342. justify-content: space-between;
  343. margin: 20px 0;
  344. }
  345. .ico{
  346. height:14px;
  347. transition: all 0.4s;
  348. vertical-align: middle;
  349. }
  350. /deep/ .ivu-card{
  351. border-radius: 15px;
  352. margin: 15px 0;
  353. background: rgb(236, 236, 236);
  354. }
  355. .btn_set{
  356. display: flex;
  357. }
  358. </style>