invoice.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. define({
  2. name: "invoice",
  3. template: `
  4. <div>
  5. <div class="vue-main-title">
  6. <div class="vue-main-title-left"></div>
  7. <div class="vue-main-title-content">发票设置</div>
  8. </div>
  9. <div style="margin:0 auto;width:100%;">
  10. <el-form label-width="130px">
  11. <el-form-item label="赋码方式" >
  12. <el-radio v-model="search.coding_type" :label="0">按商品赋码</el-radio>
  13. <el-radio v-model="search.coding_type" :label="1">按规格赋码</el-radio>
  14. </el-form-item>
  15. <el-form-item label=" " v-if="search.coding_type == 0">
  16. <div style="display: flex;">
  17. <el-input v-model="keyword" style="margin-right: 20px;width:25%;"></el-input>
  18. <el-button type="primary" @click="serachContent">搜索</el-button>
  19. </div>
  20. </el-form-item>
  21. <el-form-item label=" " v-if="search.coding_type == 0">
  22. <div style="display: flex;">
  23. <div style="flex:1;height: 360px;overflow: auto;margin-right: 20px;">
  24. <el-tree
  25. class="filter-tree"
  26. :data="dataList"
  27. :props="defaultProps"
  28. :filter-node-method="filterNode"
  29. @node-click="handleNodeClick"
  30. ref="tree">
  31. </el-tree>
  32. </div>
  33. <div style="flex:2">
  34. <div style="display: flex;flex-wrap: wrap;margin-bottom:20px;">
  35. <div style="display: flex;width:50%;margin-right: 30px;"><span>税收分类编码: </span><el-input v-model="search.code" style="max-width: 80%;"></el-input></div>
  36. <div style="display: flex;width:45%;"><span>商品名称: </span><el-input v-model="search.goods_name" style="max-width: 80%;"></el-input></div>
  37. </div>
  38. <div style="display: flex;flex-wrap: wrap;margin-bottom:20px;">
  39. <div style="display: flex;width:50%;margin-right: 30px;"><span>税收分类简称: </span><el-input v-model="search.name" style="max-width: 80%;"></el-input></div>
  40. <!-- <div style="display: flex;width:45%;"><span>商品简码: </span><el-input v-model="search.commodity_code" style="max-width: 80%;"></el-input></div> -->
  41. </div>
  42. <div style="display: flex;flex-wrap: wrap;margin-bottom:20px;">
  43. <div style="flex:1;">
  44. <span style="margin: 0 5px 5px 0;">使用优惠政策: </span>
  45. <el-radio v-model="search.use_discount" :label="1">是</el-radio>
  46. <el-radio v-model="search.use_discount" :label="0">否</el-radio>
  47. </div>
  48. <div style="flex:1;">
  49. <span>优惠政策类型: </span>
  50. <el-select v-model="search.discount" clearable placeholder="请选择" style="width: 72%;">
  51. <el-option
  52. v-for="item in use_discountType"
  53. :key="item.value"
  54. :label="item.label"
  55. :value="item.value">
  56. </el-option>
  57. </el-select>
  58. </div>
  59. </div>
  60. <div style="display: flex;flex-wrap: wrap;margin-bottom:20px;">
  61. <div style="width:48%;margin-left: 40px;">
  62. <i class="el-icon-star-on" style="color: #EE3939;font-size: 12px;margin-top: 10px;"></i>
  63. <span>税率: </span>
  64. <el-select v-model="search.tax_rate" clearable placeholder="请选择" style="width: 42%;">
  65. <el-option
  66. v-for="item in taxRate"
  67. :key="item.value"
  68. :label="item.label"
  69. :value="item.value">
  70. </el-option>
  71. </el-select>
  72. </div>
  73. <div style="display: flex;width:45%;">
  74. <i class="el-icon-star-on" style="color: #EE3939;font-size: 12px;margin-top: 10px;"></i>
  75. <span>免税类型: </span>
  76. <el-select v-model="search.tax_type" clearable placeholder="请选择" style="width: 80%;">
  77. <el-option
  78. v-for="item in dutyFree"
  79. :key="item.value"
  80. :label="item.label"
  81. :value="item.value">
  82. </el-option>
  83. </el-select>
  84. </div>
  85. </div>
  86. <div style="display: flex;margin-left: 30px;">
  87. <span style="margin: 0 5px 5px 0;">含税标志: </span>
  88. <div>
  89. <el-radio v-model="search.tax_flag" :label="1">含税</el-radio>
  90. <el-radio v-model="search.tax_flag" :label="0">不含税</el-radio>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. </el-form-item>
  96. <!-- 规格 -->
  97. <el-form-item label="批量操作" v-if="search.coding_type == 1">
  98. <span class="code-color" @click="codingDialog('')">赋码</span>
  99. </el-form-item>
  100. <el-form-item label=" " v-if="search.coding_type == 1">
  101. <el-table :data="tableColumnList.table_data" border :span-method="mergeRowComputed" style="width:30%">
  102. <el-table-column :label="specItem.attr" v-for="(specItem,itemIndex) in tableColumnList.goodsSpecs" :key="itemIndex" :prop="specItem.attr">
  103. <template slot-scope="scope">
  104. <div >{{scope.row[specItem.attr]}}</div>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="赋码" prop="stock">
  108. <template slot-scope="scope">
  109. <span @click="codingDialog(scope.$index)" class="code-color">赋码</span>
  110. <!-- <el-input v-model="scope.row.stock" :ref="'stockValueInput' + [[scope.$index]]" placeholder="0"></el-input> -->
  111. </template>
  112. </el-table-column>
  113. </el-table>
  114. </el-form-item>
  115. </el-form>
  116. </div>
  117. <!-- 弹窗 -->
  118. <el-dialog
  119. title=" "
  120. :visible.sync="dialogVisible"
  121. :show-close="false"
  122. center
  123. width="80%">
  124. <div style="border-bottom: 2px solid #b4bccc;margin-bottom: 20px;"><span style="margin:0 20px;">发票赋码</span></div>
  125. <div style="display: flex;padding:20px;">
  126. <el-input v-model="keyword" style="margin-right: 20px;width:25%;"></el-input>
  127. <el-button type="primary" @click="serachContent">搜索</el-button>
  128. </div>
  129. <div style="display: flex;padding:20px;">
  130. <div style="flex:1;height: 360px;overflow: auto;margin-right: 20px;">
  131. <el-tree
  132. class="filter-tree"
  133. :data="dataList"
  134. :props="defaultProps"
  135. :filter-node-method="filterNode"
  136. @node-click="handleNodeClick"
  137. ref="tree">
  138. </el-tree>
  139. </div>
  140. <div style="flex:2">
  141. <div style="display: flex;flex-wrap: wrap;margin-bottom:20px;">
  142. <div style="display: flex;width:50%;margin-right: 30px;"><span style="line-height: 40px;">税收分类编码: </span><el-input v-model="search.code" style="max-width: 80%;"></el-input></div>
  143. <div style="display: flex;width:45%;"><span style="line-height: 40px;">商品名称: </span><el-input v-model="search.goods_name" style="max-width: 80%;"></el-input></div>
  144. </div>
  145. <div style="display: flex;flex-wrap: wrap;margin-bottom:20px;">
  146. <div style="display: flex;width:50%;margin-right: 30px;"><span style="line-height: 40px;">税收分类简称: </span><el-input v-model="search.name" style="max-width: 80%;"></el-input></div>
  147. <!-- <div style="display: flex;width:45%;"><span style="line-height: 40px;">商品简码: </span><el-input v-model="search.commodity_code" style="max-width: 80%;"></el-input></div> -->
  148. </div>
  149. <div style="display: flex;flex-wrap: wrap;margin-bottom:20px;">
  150. <div style="flex:1;">
  151. <span style="margin: 0 5px 5px 0;line-height: 40px;" >使用优惠政策: </span>
  152. <el-radio v-model="search.use_discount" :label="1">是</el-radio>
  153. <el-radio v-model="search.use_discount" :label="0">否</el-radio>
  154. </div>
  155. <div style="flex:1;">
  156. <span style="line-height: 40px;">优惠政策类型: </span>
  157. <el-select v-model="search.discount" clearable placeholder="请选择" style="width: 80%;">
  158. <el-option
  159. v-for="item in use_discountType"
  160. :key="item.value"
  161. :label="item.label"
  162. :value="item.value">
  163. </el-option>
  164. </el-select>
  165. </div>
  166. </div>
  167. <div style="display: flex;flex-wrap: wrap;margin-bottom:20px;">
  168. <div style="width:48%;margin-left: 40px;">
  169. <i class="el-icon-star-on" style="color: #EE3939;font-size: 12px;margin-top: 10px;"></i>
  170. <span style="line-height: 40px;">税率: </span>
  171. <el-select v-model="search.tax_rate" clearable placeholder="请选择" style="width: 80%;">
  172. <el-option
  173. v-for="item in taxRate"
  174. :key="item.value"
  175. :label="item.label"
  176. :value="item.value">
  177. </el-option>
  178. </el-select>
  179. </div>
  180. <div style="display: flex;width:45%;">
  181. <i class="el-icon-star-on" style="color: #EE3939;font-size: 12px;margin-top: 10px;"></i>
  182. <span style="line-height: 40px;">免税类型: </span>
  183. <el-select v-model="search.tax_type" clearable placeholder="请选择" style="width: 80%;">
  184. <el-option
  185. v-for="item in dutyFree"
  186. :key="item.value"
  187. :label="item.label"
  188. :value="item.value">
  189. </el-option>
  190. </el-select>
  191. </div>
  192. </div>
  193. <div style="display: flex;margin-left: 30px;">
  194. <span style="margin: 0 5px 5px 0;">含税标志: </span>
  195. <div>
  196. <el-radio v-model="search.tax_flag" :label="1">含税</el-radio>
  197. <el-radio v-model="search.tax_flag" :label="0">不含税</el-radio>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <span slot="footer" class="dialog-footer">
  203. <el-button type="primary" @click="save">保 存</el-button>
  204. <el-button @click="dialogVisible = false">取 消</el-button>
  205. </span>
  206. </el-dialog>
  207. </div>
  208. `,
  209. style: `
  210. .tox-tinymce {
  211. min-height:600px;
  212. }
  213. .code-color {
  214. color:#29BA9C;
  215. font-weight: bold;
  216. }
  217. `,
  218. props: {
  219. form: {
  220. default() {
  221. return {};
  222. },
  223. },
  224. formKey: {
  225. type: String,
  226. },
  227. },
  228. data() {
  229. return {
  230. search:{
  231. coding_type: 0 ,
  232. code:'',
  233. goods_name:'',
  234. use_discount:1,
  235. name:'',
  236. // commodity_code:'',
  237. tax_rate:'',
  238. tax_type:'0',
  239. tax_flag:1,
  240. discount:''
  241. },
  242. dialogVisible: false,
  243. // 记录点击的小标
  244. columnIndex:'',
  245. use_discountType: [],
  246. taxRate: [],
  247. dutyFree:[],
  248. keyword:'',
  249. dataList: [],
  250. defaultProps: {
  251. children: 'children',
  252. label: 'mc'
  253. },
  254. tableColumnList: {
  255. goodsSpecs: [],
  256. table_data: [], // 表格中的数据
  257. },
  258. save_num:0,
  259. };
  260. },
  261. mounted() {
  262. console.log(this.form,'invoice');
  263. for(let key in this.form.taxRate){
  264. this.taxRate.push({
  265. value:key,
  266. label:this.form.taxRate[key]+'%'
  267. })
  268. }
  269. for(let key in this.form.discount){
  270. this.use_discountType.push({
  271. value:this.form.discount[key],
  272. label:this.form.discount[key]
  273. })
  274. }
  275. for(let key in this.form.exemptionType){
  276. this.dutyFree.push({
  277. value:key,
  278. label:this.form.exemptionType[key]
  279. })
  280. }
  281. this.editHandleData(this.form); // test_data测试数据
  282. this.dataList = this.form.treeCode;
  283. this.search.coding_type = this.form.invoice.coding_type;
  284. // this.form.invoice.options = this.form.invoice.options.reverse()
  285. if(this.form.invoice.coding_type == 1){
  286. this.tableColumnList.table_data.forEach((item,index) => {
  287. item.coding_type = this.form.invoice.coding_type;
  288. item.code = this.form.invoice.options[index].code ;
  289. item.goods_name = this.form.invoice.options[index].goods_name ;
  290. item.use_discount = this.form.invoice.options[index].use_discount;
  291. item.name = this.form.invoice.options[index].name;
  292. item.tax_rate = this.form.invoice.options[index].tax_rate;
  293. item.tax_type = this.form.invoice.options[index].tax_type ;
  294. item.tax_flag = this.form.invoice.options[index].tax_flag ;
  295. item.discount = this.form.invoice.options[index].discount
  296. })
  297. }else{
  298. this.search.code = this.form.invoice.code ;
  299. this.search.goods_name = this.form.invoice.goods_name ;
  300. this.search.use_discount = this.form.invoice.use_discount;
  301. this.search.name = this.form.invoice.name;
  302. this.search.tax_rate = this.form.invoice.tax_rate === 0 ? '0' : this.form.invoice.tax_rate;
  303. this.search.tax_type = this.form.invoice.tax_type ;
  304. this.search.tax_flag = this.form.invoice.tax_flag ;
  305. this.search.discount = this.form.invoice.discount;
  306. this.tableColumnList.table_data.forEach((item,index) => {
  307. item.coding_type = 1;
  308. item.code = '' ;
  309. item.goods_name = '' ;
  310. item.use_discount = 1;
  311. item.name = '';
  312. item.tax_rate = '0';
  313. item.tax_type = '0';
  314. item.tax_flag = 1;
  315. item.discount = ''
  316. })
  317. }
  318. },
  319. watch:{
  320. 'search.coding_type':{
  321. handler(newVal, oldVal){
  322. this.search.code = '';
  323. this.search.goods_name = '';
  324. this.search.use_discount = 1;
  325. this.search.name = '';
  326. this.search.discount = '';
  327. this.search.tax_rate = '0';
  328. this.search.tax_type = '0';
  329. this.search.tax_flag = 1;
  330. },
  331. }
  332. },
  333. methods: {
  334. editHandleData(data) {
  335. // 处理回显的数据
  336. for (let i = 0; i < data.specs.length; i++) {
  337. this.tableColumnList.goodsSpecs.push({
  338. id: data.specs[i].id,
  339. attr: data.specs[i].title,
  340. valueList: data.specs[i].spec_item
  341. })
  342. // 循环旧数据 规格项都对应的数据应该赋给新数据
  343. this.changeOption(data.option)
  344. }
  345. },
  346. changeOption(data) {
  347. let oldData = [];
  348. // 先保存旧的表格数据
  349. let old_table_data = JSON.parse(JSON.stringify(data));
  350. let old_data_length = old_table_data.length
  351. for (let i = 0; i < old_data_length; i++) {
  352. let title = "";
  353. this.tableColumnList.goodsSpecs.forEach((item)=> {
  354. title = title + old_table_data[i][item.attr] + '+'
  355. })
  356. oldData.push({
  357. title: title.slice(0,title.length-1),
  358. index: i
  359. })
  360. }
  361. // 重新生成处理表头数据和表格数据
  362. this.generateTableColumn();
  363. this.traverseSku();
  364. let data_length = this.tableColumnList.table_data.length
  365. for (let i = 0; i < data_length; i++) {
  366. // 循环新的表格数据进行替换
  367. let title = "";
  368. this.tableColumnList.goodsSpecs.forEach((item)=> {
  369. title = title + this.tableColumnList.table_data[i][item.attr] + '+'
  370. })
  371. oldData.forEach((item)=> {
  372. if(item.title == title.slice(0,title.length-1)) {
  373. this.tableColumnList.table_data[i].id = old_table_data[item.index].id;
  374. }
  375. })
  376. }
  377. },
  378. // 遍历 `goodsSpecs` 生成表格数据
  379. traverseSku() {
  380. let ready_map = this.generateBaseData(this.tableColumnList.goodsSpecs)
  381. this.tableColumnList.table_data = this.mergeTableData(ready_map)
  382. },
  383. // 重新实现笛卡尔积 入参是: this.tableColumnList.goodsSpecs 传入的数组 '为空', '长度为1', '长度大于1' 三种情况 分别处理
  384. generateBaseData(arr) {
  385. if (arr.length === 0) return []
  386. if (arr.length === 1) {
  387. let [item_spec] = arr
  388. return item_spec.valueList.map(x => {
  389. return {
  390. [item_spec.attr]: x.title
  391. }
  392. })
  393. }
  394. if (arr.length >= 1) {
  395. return arr.reduce((accumulator, spec_item) => {
  396. // accumulator判断是之前整合的规格数组还是单个规格项
  397. let acc_value_list = Array.isArray(accumulator.valueList) ? accumulator.valueList : accumulator
  398. let item_value_list = spec_item.valueList
  399. let result = []
  400. for (let i in acc_value_list) {
  401. for (let j in item_value_list) {
  402. let temp_data = {}
  403. if (!acc_value_list[i].title) {
  404. // accumulator不是Array的情况
  405. temp_data = {
  406. ...acc_value_list[i],
  407. [spec_item.attr]: item_value_list[j].title,
  408. // id:item_value_list[j].id
  409. }
  410. // 否则如果是单个规格项
  411. } else {
  412. temp_data[accumulator.attr] = acc_value_list[i].title
  413. temp_data[spec_item.attr] = item_value_list[j].title
  414. // temp_data['id'] = item_value_list[j].id
  415. }
  416. result.push(temp_data)
  417. }
  418. }
  419. return result
  420. })
  421. }
  422. },
  423. generateTableColumn() {
  424. // this.tableHeaderList = this.tableColumnList.goodsSpecs.map(x => x.attr).concat(['stock', 'withhold_stock', 'tax_flaget_price', 'product_price', 'cost_price', 'goods_sn', 'product_sn', 'weight', 'volume', 'thumb', ])
  425. this.tableHeaderList = this.tableColumnList.goodsSpecs.map(x => x.attr).concat([])
  426. },
  427. // 合并 goodsSpecs 与 '现价', '库存', '市场价格' , 返回整个表格数据数组
  428. mergeTableData(arr) {
  429. return arr.map((item) => {
  430. this.sp_id++;
  431. // return { ...item, id: 'SP'+ this.sp_id, 'stock': '', 'withhold_stock': '', 'tax_flaget_price': '', 'product_price': '', 'cost_price': '', 'goods_sn': '', 'product_sn': '', 'weight': '', 'volume': '', 'thumb': '', }
  432. return { ...item,id:item.id}
  433. })
  434. },
  435. // 合并单元格
  436. mergeRowComputed({ row, column, rowIndex, columnIndex }) {
  437. if (columnIndex == 0) {
  438. let key_0 = column.label
  439. let first_idx = this.tableColumnList.table_data.findIndex(x => x[key_0] == row[key_0])
  440. const calcSameLength = () => this.tableColumnList.table_data.filter(x => x[key_0] == row[key_0]).length
  441. first_column_rule = rowIndex == first_idx ? [calcSameLength(), 1] : [0, 0]
  442. return first_column_rule
  443. }else {
  444. // 表格数据的每一项,
  445. const callBacks = (table_item, start_idx = 0) => {
  446. if (columnIndex < start_idx) return true
  447. let curr_key = this.tableHeaderList[start_idx]
  448. return table_item[curr_key] === row[curr_key] && callBacks(table_item, ++start_idx)
  449. }
  450. let first_idx = this.tableColumnList.table_data.findIndex(x => callBacks(x))
  451. const calcSameLength = () => this.tableColumnList.table_data.filter(x => callBacks(x)).length
  452. return rowIndex == first_idx ? [calcSameLength(), 1] : [0, 0]
  453. }
  454. },
  455. // 弹窗
  456. codingDialog(index){
  457. if(!this.form.has_option){ return }
  458. this.dialogVisible = true;
  459. this.columnIndex = index;
  460. if(index === ''){
  461. this.search.code = '' ;
  462. this.search.goods_name = '' ;
  463. this.search.use_discount = 1;
  464. this.search.name = '';
  465. this.search.tax_rate = '0';
  466. this.search.tax_type = '0';
  467. this.search.tax_flag = 1;
  468. this.search.discount = '';
  469. }else{
  470. this.search.coding_type = this.tableColumnList.table_data[this.columnIndex].coding_type;
  471. this.search.code = this.tableColumnList.table_data[this.columnIndex].code ;
  472. this.search.goods_name = this.tableColumnList.table_data[this.columnIndex].goods_name ;
  473. this.search.use_discount = this.tableColumnList.table_data[this.columnIndex].use_discount ;
  474. this.search.name = this.tableColumnList.table_data[this.columnIndex].name ;
  475. this.search.tax_rate = this.tableColumnList.table_data[this.columnIndex].tax_rate;
  476. this.search.tax_type = this.tableColumnList.table_data[this.columnIndex].tax_type ;
  477. this.search.tax_flag = this.tableColumnList.table_data[this.columnIndex].tax_flag ;
  478. this.search.discount = this.tableColumnList.table_data[this.columnIndex].discount ;
  479. console.log(this.tableColumnList.table_data ,this.columnIndex,'this.search.discount ');
  480. // }
  481. }
  482. },
  483. filterNode(value, data) {
  484. if (!value) return true;
  485. return data.mc.indexOf(value) !== -1;
  486. },
  487. // 搜索
  488. serachContent(){
  489. this.$refs.tree.filter(this.keyword);
  490. },
  491. // 获取点击节点数据
  492. handleNodeClick(data){
  493. if(data.children.length === 0){
  494. this.search.code = data.bm;
  495. this.search.goods_name = '' ;
  496. this.search.name = data.spbmjc;
  497. // this.search.commodity_code = data.mc;
  498. }
  499. },
  500. validate(){
  501. if(this.search.tax_type === ''){
  502. this.$message.success('免税类型选项不能为空')
  503. return false
  504. }
  505. if(this.search.tax_rate === ''){
  506. this.$message.success('税率选项不能为空')
  507. return false
  508. }
  509. return this.save()
  510. },
  511. // 保存
  512. save(){
  513. this.save_num += 1;
  514. if(this.columnIndex === ''){
  515. for(let item of this.tableColumnList.table_data){
  516. item.coding_type = this.search.coding_type;
  517. item.code = this.search.code;
  518. item.goods_name = this.search.goods_name;
  519. item.use_discount = this.search.use_discount;
  520. item.name = this.search.name;
  521. // item.commodity_code = this.search.commodity_code;
  522. item.tax_rate = this.search.tax_rate;
  523. item.tax_type = this.search.tax_type;
  524. item.tax_flag = this.search.tax_flag;
  525. item.discount = this.search.discount;
  526. }
  527. }else{
  528. this.tableColumnList.table_data[this.columnIndex].coding_type = this.search.coding_type;
  529. this.tableColumnList.table_data[this.columnIndex].code = this.search.code;
  530. this.tableColumnList.table_data[this.columnIndex].goods_name = this.search.goods_name;
  531. this.tableColumnList.table_data[this.columnIndex].use_discount = this.search.use_discount;
  532. this.tableColumnList.table_data[this.columnIndex].name = this.search.name;
  533. this.tableColumnList.table_data[this.columnIndex].tax_rate = this.search.tax_rate;
  534. this.tableColumnList.table_data[this.columnIndex].tax_type = this.search.tax_type;
  535. this.tableColumnList.table_data[this.columnIndex].tax_flag = this.search.tax_flag;
  536. this.tableColumnList.table_data[this.columnIndex].discount = this.search.discount;
  537. }
  538. this.dialogVisible = false;
  539. let options = []
  540. for(let item of this.tableColumnList.table_data){
  541. options.push({
  542. // coding_type : this.search.coding_type,
  543. code : item.code,
  544. name : item.name,
  545. use_discount : item.use_discount,
  546. discount : item.discount,
  547. tax_type : item.tax_type,
  548. tax_rate : item.tax_rate,
  549. goods_name : item.goods_name,
  550. // goods_code : item.commodity_code,
  551. tax_flag : item.tax_flag,
  552. goods_option_id : item.id
  553. })
  554. }
  555. let invoice = {
  556. coding_type : this.search.coding_type,
  557. code : this.search.coding_type ? '' : this.search.code,
  558. name : this.search.coding_type ? '' : this.search.name,
  559. use_discount : this.search.coding_type ? 1 : this.search.use_discount,
  560. discount : this.search.coding_type ? '' : this.search.discount,
  561. tax_type : this.search.coding_type ? '' : this.search.tax_type,
  562. tax_rate : this.search.coding_type ? '' : this.search.tax_rate,
  563. goods_name : this.search.coding_type ? '' : this.search.goods_name,
  564. // goods_code : this.search.commodity_code,
  565. tax_flag : this.search.coding_type ? 1 : this.search.tax_flag,
  566. options : this.search.coding_type && this.form.has_option == 1 ? options : []
  567. }
  568. console.log(invoice,'options',this.tableColumnList.table_data,this.search.goods_name);
  569. return invoice
  570. }
  571. },
  572. });