Authored by zhangwenxue

refactor(finance/invoice): style

@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 </template> 36 </template>
37 </Form> 37 </Form>
38 <div slot="footer" class="modal-footer"> 38 <div slot="footer" class="modal-footer">
39 - <span v-if="formItem.status !== UNOPEN"><i>*</i>在第三方开票系统冲红或作废后更新保存发票信息</span> 39 + <span v-if="formItem.status !== UNOPEN"><i>*</i> 在第三方开票系统冲红或作废后更新保存发票信息</span>
40 <Button type="primary" :loading="inLoading" @click="update">保存</Button> 40 <Button type="primary" :loading="inLoading" @click="update">保存</Button>
41 <Button @click="close">关闭</Button> 41 <Button @click="close">关闭</Button>
42 </div> 42 </div>
@@ -144,6 +144,10 @@ export default { @@ -144,6 +144,10 @@ export default {
144 logisticsSwitch: this.LOGISTICS_YES, 144 logisticsSwitch: this.LOGISTICS_YES,
145 ...invoice, 145 ...invoice,
146 }; 146 };
  147 + // transfer CANCELLED state to invoice type
  148 + if (this.formItem.status === InvoiceStatusName2Id.CANCELLED) {
  149 + this.formItem.type = InvoiceStatusName2Id.CANCELLED;
  150 + }
147 this.visible = true; 151 this.visible = true;
148 }, 152 },
149 /** 153 /**
@@ -180,7 +184,7 @@ export default { @@ -180,7 +184,7 @@ export default {
180 const isCancled = invoice.status === InvoiceStatusName2Id.CANCELLED; 184 const isCancled = invoice.status === InvoiceStatusName2Id.CANCELLED;
181 185
182 if (isCancled) { 186 if (isCancled) {
183 - if (currentStatus === isCancled) { 187 + if (currentStatus === InvoiceStatusName2Id.CANCELLED) {
184 return false; 188 return false;
185 } 189 }
186 190
@@ -216,16 +220,38 @@ export default { @@ -216,16 +220,38 @@ export default {
216 220
217 return true; 221 return true;
218 }, 222 },
219 - update() {  
220 - const params = { ...this.formItem }; 223 + validate(callback) {
  224 + if (this.$refs.modal.fields.length !== 0) {
  225 + return this.$refs.modal.validate(callback);
  226 + }
221 227
  228 + return callback(true);
  229 + },
  230 + update() {
222 // validate 231 // validate
223 - this.$refs.modal.validate(valid => { 232 + this.validate(valid => {
224 if (valid) { 233 if (valid) {
  234 + // only whitelist
  235 + const params = _.pick(this.formItem, [
  236 + 'shopId',
  237 + 'orderCode',
  238 + 'status',
  239 + 'step',
  240 + // issueDate
  241 + 'pdfUrl',
  242 + 'type',
  243 + 'logisticsId',
  244 + // logisticsCompanyName
  245 + 'expressNumber',
  246 + 'logisticsSwitch',
  247 + ]);
  248 +
  249 + // clean data?
225 if (!this.updateState(params)) { 250 if (!this.updateState(params)) {
226 - this.close(true); 251 + this.close();
227 return; 252 return;
228 } 253 }
  254 +
229 this.inLoading = true; 255 this.inLoading = true;
230 this.invoiceAPI 256 this.invoiceAPI
231 .update(params) 257 .update(params)
@@ -241,13 +267,8 @@ export default { @@ -241,13 +267,8 @@ export default {
241 }); 267 });
242 } 268 }
243 }); 269 });
244 - // TODO:  
245 - // update status  
246 }, 270 },
247 - close(force) {  
248 - if (!force) {  
249 - // dirty check  
250 - } 271 + close() {
251 this.visible = false; 272 this.visible = false;
252 }, 273 },
253 onPDFUrlChang() { 274 onPDFUrlChang() {
@@ -54,17 +54,6 @@ export default { @@ -54,17 +54,6 @@ export default {
54 uploadList: [], 54 uploadList: [],
55 }; 55 };
56 }, 56 },
57 - // watch: {  
58 - // value: {  
59 - // handler(newVal) {  
60 -  
61 - // },  
62 - // },  
63 - // computed: {  
64 - // uploadList() {  
65 - // return this.$refs.upload.fileList;  
66 - // },  
67 - // },  
68 mounted() { 57 mounted() {
69 this.clearFileList(); 58 this.clearFileList();
70 this.unwatch = this.$watch( 59 this.unwatch = this.$watch(
@@ -99,17 +88,12 @@ export default { @@ -99,17 +88,12 @@ export default {
99 }, 88 },
100 methods: { 89 methods: {
101 clearFileList() { 90 clearFileList() {
102 - // const fileList = ;  
103 - // fileList.splice(0, fileList.length); // delete all  
104 - // return fileList;  
105 this.uploadList = this.$refs.upload.fileList = []; 91 this.uploadList = this.$refs.upload.fileList = [];
106 }, 92 },
107 handleView() { 93 handleView() {
108 this.visible = true; 94 this.visible = true;
109 }, 95 },
110 handleRemove() { 96 handleRemove() {
111 - // const fileList = this.$refs.upload.fileList;  
112 - // this.$refs.upload.fileList.splice(fileList.indexOf(file), 1);  
113 this.clearFileList(); 97 this.clearFileList();
114 this.$emit('input', null); 98 this.$emit('input', null);
115 }, 99 },
@@ -220,9 +220,6 @@ export default { @@ -220,9 +220,6 @@ export default {
220 .text-red { 220 .text-red {
221 color: #ed3f14; 221 color: #ed3f14;
222 } 222 }
223 -.date-picker {  
224 - // width: 250px !important;  
225 -}  
226 .layout-filter /deep/ { 223 .layout-filter /deep/ {
227 .ivu-col-span-6:nth-child(2) { 224 .ivu-col-span-6:nth-child(2) {
228 width: 400px; 225 width: 400px;