edit.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  1. <template>
  2. <div>
  3. <Toptitle :title="$route.query.type==1?'新增到货单':$route.query.type==2?'查看到货单':'编辑到货单'">
  4. <slot name="titleButton">
  5. <Button type="primary" ghost style="margin-right: 10px" v-if="$route.query.type==2" @click="examine"
  6. >{{searchData.state==0?'审批':'弃审'}}</Button
  7. >
  8. <Button type="primary" ghost style="margin-right: 10px" v-if="$route.query.type==2" @click="typeChange(1)"
  9. >打开</Button
  10. >
  11. <Button type="primary" ghost style="margin-right: 10px" v-if="$route.query.type==2" @click="typeChange(0)"
  12. >关闭</Button
  13. >
  14. <Button type="primary" ghost style="margin-right: 10px"
  15. >栏目设置</Button
  16. >
  17. <Button @click="handleReference(2,searchData.supply_title)"
  18. type="primary"
  19. ghost
  20. v-show="!isCheck&&$route.query.type!=3"
  21. style="margin-right:10px;">参照采购单</Button>
  22. <Button @click="goBack"
  23. type="primary"
  24. ghost
  25. style="margin-right:10px;">返回</Button>
  26. <Button @click="postData"
  27. type="primary"
  28. ghost
  29. v-show="!isCheck"
  30. style="margin-right:10px;">确定</Button>
  31. </slot>
  32. </Toptitle>
  33. <div style="height:90%;overflow:auto">
  34. <div class="content_topform">
  35. <Form :label-width="100"
  36. :model="searchData">
  37. <!-- <FormItem label="项目名称:">
  38. <Input type="text"
  39. size="small"
  40. v-model="searchData.client_name"
  41. style="width: 200px;margin-top:6px"
  42. placeholder="项目名称">
  43. <span slot="append"
  44. style="cursor:pointer;"
  45. @click="showProjectModal=true">选择</span>
  46. </Input>
  47. </FormItem> -->
  48. <FormItem label="到货单号:">
  49. <Input type="text"
  50. v-show="!isCheck"
  51. size="small"
  52. readonly
  53. v-model="searchData.arrival_no"
  54. disabled
  55. style="width: 200px"
  56. placeholder="自动生成" />
  57. <span v-show="isCheck">{{searchData.arrival_no}}</span>
  58. </FormItem>
  59. <FormItem label="供应商名称:">
  60. <Input type="text"
  61. size="small"
  62. v-model="searchData.supply_title"
  63. v-show="!isCheck"
  64. style="width: 200px;"
  65. placeholder="供应商名称">
  66. <!-- <span slot="append"
  67. style="cursor:pointer;"
  68. @click="showSupplierModal=true">选择</span> -->
  69. </Input>
  70. <span v-show="isCheck">{{searchData.supply_title}}</span>
  71. </FormItem>
  72. <FormItem label="制单人:"
  73. v-show="isCheck">
  74. <!-- <Input type="text"
  75. size="small"
  76. v-model="searchData.nickname"
  77. style="width: 200px"
  78. placeholder="制单人" /> -->
  79. <span>{{searchData.user_name}}</span>
  80. </FormItem>
  81. <FormItem label="单据日期:" class="order_time">
  82. <DatePicker type="date"
  83. size="small"
  84. v-show="!isCheck"
  85. style="width: 200px"
  86. placeholder="年/月/日"
  87. v-model="searchData.order_time"></DatePicker>
  88. <span v-show="isCheck">{{func.replaceDateNoHMS(searchData.order_time)}}</span>
  89. </FormItem>
  90. <FormItem label='审批人:' v-if="$route.query.type==2">
  91. <span>{{searchData.check_name?searchData.check_name:''}}</span>
  92. </FormItem>
  93. <FormItem label='审批状态:' v-if="$route.query.type==2">
  94. <span>{{searchData.state==0?'未审批':'已审批'}}</span>
  95. </FormItem>
  96. <FormItem label='订单创建时间:' v-if="$route.query.type==2" >
  97. <span>{{searchData.crt_time?func.replaceDate(searchData.crt_time):''}}</span>
  98. </FormItem>
  99. <!-- <FormItem label="预计到货:">
  100. <DatePicker type="date"
  101. size="small"
  102. v-show="!isCheck"
  103. style="width: 200px"
  104. placeholder="年/月/日"
  105. v-model="searchData.arrive_time"></DatePicker>
  106. <span v-show="isCheck">{{func.replaceDateNoHMS(searchData.arrive_time)}}</span>
  107. </FormItem> -->
  108. <FormItem label="备注:">
  109. <Input type="textarea"
  110. size="small"
  111. v-show="!isCheck"
  112. v-model="searchData.remark"
  113. style="width: 200px"
  114. placeholder="备注" />
  115. <span v-show="isCheck">{{searchData.remark}}</span>
  116. </FormItem>
  117. </Form>
  118. </div>
  119. <div class="content_table">
  120. <div class="content_table_btn">
  121. <div>
  122. <span>到货质检清单</span>
  123. <!-- <Button @click="showModal=true"
  124. type="primary"
  125. size="small"
  126. style="margin-left:10px;">选择物料</Button> -->
  127. </div>
  128. <div class="content_table_btn_right">
  129. </div>
  130. </div>
  131. <Table :columns="tableColumns"
  132. border
  133. show-summary
  134. :summary-method="handleSummary"
  135. @on-selection-change='selectRow'
  136. :data="tableData">
  137. <template slot="numberSet" slot-scope="{row , index }">
  138. <Tooltip
  139. placement="left"
  140. @on-popper-show="handleToolShow(index, row)"
  141. >
  142. <div slot="content">
  143. <div>
  144. <div v-for="(_item,_index) in warehouse" :key="_index">
  145. {{_item.warehouse_title}}:{{_item.num}}
  146. </div>
  147. </div>
  148. </div>
  149. <span >{{ tableData[index].num }}</span>
  150. </Tooltip>
  151. </template>
  152. <template slot="reference_num" slot-scope="{row}">
  153. <span>{{row.num-row.reference_num}}</span>
  154. </template>
  155. <template slot="setSlot"
  156. slot-scope="{row,index}">
  157. <a style="margin:0 5px"
  158. v-show="!isCheck"
  159. @click="handleSet(4,row,index)">删除</a>
  160. </template>
  161. </Table>
  162. </div></div>
  163. <Modal v-model="showModal"
  164. title="选择物料"
  165. width='80'
  166. @on-ok="handleSelect"
  167. @on-cancel="showModal=false">
  168. <div class="modal_content">
  169. <div class="modal_content_left">
  170. <Tree :data="modalData.treeData"
  171. children-key='list'
  172. style="width:100%;"
  173. @on-select-change="handleTreeSlect"
  174. class="demo-tree-render"></Tree>
  175. </div>
  176. <div class="modal_content_center">
  177. <div class="modal_content_center_top">
  178. <div><span>物料名称:</span>
  179. <Input type="text"
  180. v-model="modalData.title"
  181. clearable
  182. placeholder="请输入物料名称" />
  183. </div>
  184. <Button @click="initModal()"
  185. type="primary"
  186. style="margin:0 10px;">搜索</Button>
  187. </div>
  188. <div class="modal_content_center_body">
  189. <Table :columns="modalTableColumns"
  190. height="520"
  191. border
  192. @on-select="handleSelection"
  193. :loading="modalTableLoading"
  194. :data="modalData.tableData">
  195. </Table>
  196. <div class="modal_content_center_footer">
  197. <Page :page-size-opts="[10, 20, 30, 40,100]"
  198. @on-page-size-change='changeModalSize'
  199. @on-change='changeModalPage'
  200. :current='modal_page_index'
  201. show-total
  202. :total="modal_total"
  203. show-sizer
  204. :page-size='modal_page_size' />
  205. </div>
  206. </div>
  207. </div>
  208. <div class="modal_content_right">
  209. <span>已选</span>
  210. <Table :columns="selectedColumns"
  211. max-height="500"
  212. border
  213. :data="modalData.selectedData">
  214. <template slot="selectedSetSlot"
  215. slot-scope="{row,index}">
  216. <a style="margin:0 5px;color:red"
  217. @click="handleSelectedDele(row,index)">删除</a>
  218. </template>
  219. </Table>
  220. </div>
  221. </div>
  222. </Modal>
  223. <Modal v-model="showProjectModal"
  224. title="选择项目"
  225. width='80'
  226. @on-ok="handleProjectSelect"
  227. @on-cancel="showProjectModal=false">
  228. <div class="modal_content">
  229. <div class="modal_content_center">
  230. <div class="modal_content_center_top">
  231. <span>项目名称:</span>
  232. <Input type="text"
  233. v-model="modalProjectData.title"
  234. style="width:180px"
  235. placeholder="请输入物料名称" />
  236. <Button @click="initProjectModal()"
  237. type="primary"
  238. style="margin:0 10px;">搜索</Button>
  239. </div>
  240. <div class="modal_content_center_body">
  241. <Table :columns="modalProjectTableColumns"
  242. height="520"
  243. border
  244. :loading="modalProjectTableLoading"
  245. :data="modalProjectData.tableData">
  246. <template slot="basicTypeSet"
  247. slot-scope="{row}">
  248. <div>
  249. <span v-for="item in warningList"
  250. :key="item.id"
  251. :style="{color:item.color}"
  252. v-show="item.id==row.warning_state">{{item.title}}</span>
  253. </div>
  254. </template>
  255. </Table>
  256. <div class="modal_content_center_footer">
  257. <Page :page-size-opts="[10, 20, 30, 40,100]"
  258. @on-page-size-change='changeProjectModalSize'
  259. @on-change='changeProjectModalPage'
  260. :current='modal_project_page_index'
  261. show-total
  262. :total="modal_project_total"
  263. show-sizer
  264. :page-size='modal_project_page_size' />
  265. </div>
  266. </div>
  267. </div>
  268. </div>
  269. </Modal>
  270. <Modal v-model="showSupplierModal"
  271. title="选择供应商"
  272. width='80'
  273. @on-ok="handleSupplierSelect"
  274. @on-cancel="showSupplierModal=false">
  275. <div class="modal_content">
  276. <div class="modal_content_left">
  277. <Tree :data="modalSupplierData.treeData"
  278. children-key='sub'
  279. style="width:100%;"
  280. @on-select-change="handleSupplierTreeSlect"
  281. class="demo-tree-render"></Tree>
  282. </div>
  283. <div class="modal_content_center">
  284. <div class="modal_content_center_top">
  285. <span>供应商名称:</span>
  286. <Input type="text"
  287. v-model="modalSupplierData.title"
  288. style="width:180px"
  289. placeholder="请输入供应商名称" />
  290. <Button @click="initSupplierModal(modalSupplierData)"
  291. type="primary"
  292. style="margin:0 10px;">搜索</Button>
  293. </div>
  294. <div class="modal_content_center_body">
  295. <Table :columns="modalSupplierTableColumns"
  296. height="520"
  297. border
  298. :loading="modalSupplierTableLoading"
  299. :data="modalSupplierData.tableData">
  300. </Table>
  301. <div class="modal_content_center_footer">
  302. <Page :page-size-opts="[10, 20, 30, 40,100]"
  303. @on-page-size-change='changeSupplierModalSize'
  304. @on-change='changeSupplierModalPage'
  305. :current='modal_supplier_page_index'
  306. show-total
  307. :total="modal_supplier_total"
  308. show-sizer
  309. :page-size='modal_supplier_page_size' />
  310. </div>
  311. </div>
  312. </div>
  313. </div>
  314. </Modal>
  315. </div>
  316. </template>
  317. <script>
  318. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  319. // 例如:import 《组件名称》 from '《组件路径》';
  320. export default {
  321. name: '',
  322. components: {
  323. },
  324. props: {},
  325. // import引入的组件需要注入到对象中才能使用
  326. data () {
  327. // 这里存放数据
  328. return {
  329. fax_modify: '',
  330. searchData: {
  331. order_time:new Date().toLocaleString(),
  332. supply_title:''
  333. },
  334. modalProjectData: {
  335. title: '',
  336. tableData: [{}]
  337. },
  338. modalSupplierData: {
  339. title: '',
  340. code: '',
  341. treeData: [
  342. {
  343. title: '供应商分类',
  344. expand: true,
  345. sub: [],
  346. render: (h, { root, node, data }) => {
  347. return h('span', {
  348. style: {
  349. display: 'inline-block',
  350. width: '100%'
  351. }
  352. }, [
  353. h('span', [
  354. h('Icon', {
  355. props: {
  356. type: 'ios-folder-outline'
  357. },
  358. style: {
  359. marginRight: '8px'
  360. }
  361. }),
  362. h('span', data.title)
  363. ]),
  364. h('span', {
  365. style: {
  366. display: 'inline-block',
  367. // float: 'right',
  368. marginRight: '32px'
  369. }
  370. })
  371. ]);
  372. },
  373. }
  374. ],
  375. tableData: [{}]
  376. },
  377. tableColumns: [
  378. { title: '物料分类', key: 'type_title', align: 'center', minWidth: 140 },
  379. { title: '物料名称', key: 'title', align: 'center', minWidth: 140 },
  380. {
  381. title: '物料规格', key: '', align: 'center', minWidth: 140,
  382. render: (h, params) => {
  383. const { row } = params
  384. let text = `${row.long}*${row.width}*${row.high}`
  385. return h('span', {}, text)
  386. }
  387. },
  388. { title: '计量单位', key: 'unit', align: 'center', minWidth: 100 },
  389. {
  390. title: '数量', key: 'num', align: 'center', minWidth: 120,slot:'numberSet'
  391. // render: (h, params) => {
  392. // const { row, index } = params
  393. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  394. // return this.isCheck ? h('span', currentRow.num) : h('Input', {
  395. // props: {
  396. // value: currentRow.num,
  397. // type: 'text'
  398. // },
  399. // on: {
  400. // 'on-change': (e) => {
  401. // currentRow.num = e.target.value
  402. // currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  403. // currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  404. // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  405. // this.tableData.splice(index, 1, currentRow);
  406. // }
  407. // }
  408. // })
  409. // }
  410. },
  411. {
  412. title: '无税单价', key: 'no_tax_price', align: 'center', minWidth: 120,
  413. // render: (h, params) => {
  414. // const { row, index } = params
  415. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  416. // return h('Input', {
  417. // props: {
  418. // value: currentRow.no_tax_price,
  419. // type: 'text'
  420. // },
  421. // on: {
  422. // 'on-change': (e) => {
  423. // currentRow.no_tax_price = e.target.value
  424. // currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  425. // currentRow.price = (1 * currentRow.no_tax_price * (1 + 1 * currentRow.fax / 100)).toFixed(2)
  426. // currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  427. // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  428. // // currentRow.total_price = (1 * currentRow.no_tax_amount + 1 * currentRow.tax_amount).toFixed(2)
  429. // this.tableData.splice(index, 1, currentRow);
  430. // }
  431. // }
  432. // })
  433. // }
  434. },
  435. {
  436. title: '税率(%)', key: 'tax_rate', align: 'center', minWidth: 120,
  437. render:(h,params)=>{
  438. const { row, index } = params
  439. const text = `${row.tax_rate*100}%`
  440. return h('span',{},text)
  441. }
  442. // render: (h, params) => {
  443. // const { row, index } = params
  444. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  445. // return h('Input', {
  446. // props: {
  447. // value: currentRow.fax,
  448. // type: 'text',
  449. // },
  450. // on: {
  451. // 'on-change': (e) => {
  452. // currentRow.fax = e.target.value
  453. // currentRow.price = (1 * currentRow.no_tax_price * (1 + 1 * currentRow.fax / 100)).toFixed(2)
  454. // currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  455. // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  456. // this.tableData.splice(index, 1, currentRow);
  457. // }
  458. // }
  459. // }, [h('span', { slot: 'append' }, '%')])
  460. // }
  461. },
  462. {
  463. title: '含税单价', key: 'price', align: 'center', minWidth: 120,
  464. // render: (h, params) => {
  465. // const { row, index } = params
  466. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  467. // return h('Input', {
  468. // props: {
  469. // value: currentRow.price,
  470. // type: 'text'
  471. // },
  472. // on: {
  473. // 'on-change': (e) => {
  474. // currentRow.price = e.target.value
  475. // currentRow.no_tax_price = (1 * currentRow.price / (1 + 1 * currentRow.fax / 100)).toFixed(2)
  476. // currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  477. // currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  478. // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_price).toFixed(2)
  479. // this.tableData.splice(index, 1, currentRow);
  480. // }
  481. // }
  482. // })
  483. // }
  484. },
  485. {
  486. title: '无税金额', key: 'no_tax_total_price', align: 'center', minWidth: 120,
  487. // render: (h, params) => {
  488. // const { row, index } = params
  489. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  490. // return h('Input', {
  491. // props: {
  492. // value: currentRow.no_tax_amount,
  493. // type: 'text'
  494. // },
  495. // on: {
  496. // 'on-change': (e) => {
  497. // currentRow.no_tax_amount = e.target.value
  498. // currentRow.no_tax_price = (1 * currentRow.no_tax_amount / currentRow.num).toFixed(2)
  499. // currentRow.price = (1 * currentRow.no_tax_price * (1 + 1 * currentRow.fax / 100)).toFixed(2)
  500. // currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  501. // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_price).toFixed(2)
  502. // this.tableData.splice(index, 1, currentRow);
  503. // }
  504. // }
  505. // })
  506. // }
  507. },
  508. {
  509. title: '税额', key: 'tax_total_price', align: 'center', minWidth: 120,
  510. // render: (h, params) => {
  511. // const { row, index } = params
  512. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  513. // return h('Input', {
  514. // props: {
  515. // value: currentRow.tax_amount,
  516. // type: 'text',
  517. // },
  518. // on: {
  519. // 'on-change': (e) => {
  520. // currentRow.tax_amount = e.target.value
  521. // currentRow.fax = (1 * currentRow.tax_amount / currentRow.no_tax_price).toFixed(2)
  522. // this.tableData.splice(index, 1, currentRow);
  523. // }
  524. // }
  525. // })
  526. // }
  527. },
  528. {
  529. title: '价格合计', key: 'total_price', align: 'center', minWidth: 120,
  530. // render: (h, params) => {
  531. // const { row, index } = params
  532. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  533. // return h('Input', {
  534. // props: {
  535. // value: currentRow.total_price,
  536. // type: 'text',
  537. // },
  538. // on: {
  539. // 'on-change': (e) => {
  540. // currentRow.total_price = e.target.value
  541. // currentRow.price = (1 * currentRow.total_price / currentRow.num).toFixed(2)
  542. // currentRow.no_tax_price = (1 * currentRow.price / (1 + 1 * currentRow.fax / 100)).toFixed(2)
  543. // currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  544. // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  545. // this.tableData.splice(index, 1, currentRow);
  546. // }
  547. // }
  548. // })
  549. // }
  550. },
  551. { title: '操作', key: 'code', align: 'center', minWidth: 100, slot: 'setSlot' },
  552. ],
  553. tableData: [
  554. // {
  555. // num: '',
  556. // no_tax_price: '',
  557. // fax: '',
  558. // price: '',
  559. // no_tax_amount: '',
  560. // tax_amount: '',
  561. // total_price: ''
  562. // }
  563. ],
  564. warehouse:'',
  565. showModal: false,
  566. showProjectModal: false,
  567. showSupplierModal: false,
  568. modalTableLoading: false,
  569. modalProjectTableLoading: false,
  570. modalSupplierTableLoading: false,
  571. modal_project_page_index: 1,
  572. modal_project_page_size: 10,
  573. modal_project_total: 0,
  574. modal_supplier_page_index: 1,
  575. modal_supplier_page_size: 10,
  576. modal_supplier_total: 0,
  577. currentChoose: {},
  578. modalProjectTableColumns: [
  579. {
  580. title: '选择', key: '', align: 'center', minWidth: 60,
  581. render: (h, params) => {
  582. let id = params.row.id;
  583. let flag = false;
  584. if (this.currentChoose.id == id) {
  585. flag = true
  586. } else {
  587. flag = false
  588. }
  589. let self = this
  590. return h('div', [
  591. h('Radio', {
  592. props: {
  593. value: flag
  594. },
  595. on: {
  596. 'on-change': () => {
  597. self.currentChoose = params.row;
  598. }
  599. }
  600. })
  601. ])
  602. }
  603. },
  604. { title: '项目名称', key: 'client_name', align: 'center', minWidth: 100 },
  605. { title: '紧急程度', align: 'center', key: 'warning_state', minWidth: 80, slot: 'basicTypeSet', },
  606. {
  607. title: '创建时间', key: 'crt_time', align: 'center', minWidth: 110,
  608. render: (h, params) => {
  609. const { row } = params
  610. return h('span', {}, this.func.replaceDate(row.crt_time))
  611. }
  612. },
  613. ],
  614. modalSupplierTableColumns: [
  615. {
  616. title: '选择', key: '', align: 'center', minWidth: 60,
  617. render: (h, params) => {
  618. let id = params.row.id;
  619. let flag = false;
  620. if (this.currentChoose.id == id) {
  621. flag = true
  622. } else {
  623. flag = false
  624. }
  625. let self = this
  626. return h('div', [
  627. h('Radio', {
  628. props: {
  629. value: flag
  630. },
  631. on: {
  632. 'on-change': () => {
  633. self.currentChoose = params.row;
  634. }
  635. }
  636. })
  637. ])
  638. }
  639. },
  640. { title: '供应商编码', key: 'code', align: 'center', minWidth: 100 },
  641. { title: '供应商名称', key: 'title', align: 'center', minWidth: 80, },
  642. { title: '负责人', key: 'contact', align: 'center', minWidth: 110, },
  643. { title: '联系方式', key: 'mobile', align: 'center', minWidth: 110, },
  644. ],
  645. modalData: {
  646. title: '',
  647. tableData: [{}],
  648. selectedData: [],
  649. treeData: [
  650. {
  651. title: '物料分类',
  652. expand: true,
  653. list: [],
  654. render: (h, { root, node, data }) => {
  655. return h('span', {
  656. style: {
  657. display: 'inline-block',
  658. width: '100%'
  659. }
  660. }, [
  661. h('span', [
  662. h('Icon', {
  663. props: {
  664. type: 'ios-folder-outline'
  665. },
  666. style: {
  667. marginRight: '8px'
  668. }
  669. }),
  670. h('span', data.title)
  671. ]),
  672. h('span', {
  673. style: {
  674. display: 'inline-block',
  675. // float: 'right',
  676. marginRight: '32px'
  677. }
  678. })
  679. ]);
  680. },
  681. }
  682. ],
  683. },
  684. selectedColumns: [
  685. { title: '物料名称', key: 'title', align: 'center', minWidth: 110 },
  686. { title: '操作', key: 'title', align: 'center', minWidth: 90, slot: 'selectedSetSlot' },
  687. ],
  688. modal_page_index: 1,
  689. modal_page_size: 10,
  690. modal_total: 0,
  691. modalTableColumns: [
  692. { title: '全选', type: 'selection', align: 'center', minWidth: 60 },
  693. { title: '物料名称', key: 'title', align: 'center', minWidth: 110 },
  694. { title: '物料规格', key: 'model', align: 'center', minWidth: 110 },
  695. { title: '计量单位', key: 'unit', align: 'center', minWidth: 110 },
  696. ],
  697. isCheck: false,
  698. warningList: [],
  699. purchase_data:[],
  700. purchase_tableData:[],
  701. selectChoose:[],
  702. del_list:[],
  703. }
  704. },
  705. // 生命周期 - 创建完成(可以访问当前this实例)
  706. created () {
  707. this.$route.query.type == 2 ? this.isCheck = true : this.isCheck = false
  708. // 获取基础物料类型
  709. this.axios({ method: 'get', url: '/api/basics_material_index_level', }).then((res) => { this.modalData.treeData[0].list = res.data }).catch((err) => { });
  710. // 获取供应商列表
  711. this.axios({ method: 'get', url: '/api/supply_list', }).then((res) => { this.suppliersList = res.data.data }).catch((err) => { });
  712. // 获取供应商分类
  713. this.axios({ method: 'get', url: '/api/basic_supply_list', }).then((res) => { this.modalSupplierData.treeData[0].sub = res.data }).catch((err) => { });
  714. // 获取项目列表
  715. this.axios({ method: 'get', url: '/api/order_index', }).then((res) => {
  716. this.modalProjectData.tableData = res.data.data
  717. this.modal_project_total = res.data.total
  718. }).catch((err) => { });
  719. // 获取紧急程度
  720. this.axios.get('/api/warning_list').then(res => { this.warningList = res.data.data })
  721. this.initModal()
  722. this.initProjectModal()
  723. this.initSupplierModal(this.modalSupplierData)
  724. },
  725. // 生命周期 - 挂载完成(可以访问DOM元素)
  726. mounted () {
  727. if (this.$route.query.type != 1) {
  728. this.initData(this.$route.query.arrival_no)
  729. }
  730. if(this.$route.query.type == 2){
  731. this.tableColumns.pop();
  732. this.tableColumns.splice(5,0,{
  733. title:'未参照数量',key:'reference_num',align:'center',minWidth:120,slot:'reference_num'
  734. })
  735. this.tableColumns.unshift({
  736. align:'center',
  737. minWidth:80,
  738. type:"selection",
  739. key:"select"
  740. })
  741. this.tableColumns.push({
  742. title: "状态",
  743. key: "lock",
  744. align: "center",
  745. minWidth: 100,
  746. render: (h, params) => {
  747. const { row } = params
  748. let text = row.lock==1?'打开':'关闭'
  749. return h('span', {
  750. }, text)
  751. },
  752. })
  753. }
  754. },
  755. methods: {
  756. typeChange(val){
  757. if(this.selectChoose.length==0){
  758. return this.$Message.warning("请先选择物料")
  759. }
  760. let id=[];
  761. this.selectChoose.forEach(v=>{
  762. id.push(v.id);
  763. })
  764. let state = val;
  765. this.axios.post('/api/purchase_arrive_switch',{id,state}).then((res)=>{
  766. if(res.code==200){
  767. this.$Message.success(res.msg);
  768. this.initData(this.$route.query.arrival_no);
  769. }
  770. })
  771. },
  772. selectRow(e){
  773. this.selectChoose = e;
  774. },
  775. examine(){
  776. let state='';
  777. if(this.searchData.state == 0){
  778. state = 1;
  779. }else{
  780. state = 0;
  781. }
  782. this.axios.get('/api/purchase_arrive_check',{params:{state,arrival_no:this.$route.query.arrival_no}}).then((res)=>{
  783. if(res.code==200){
  784. this.$Message.success(res.msg);
  785. this.initData(this.$route.query.arrival_no)
  786. }
  787. })
  788. },
  789. handleToolShow(index, row) {
  790. if (this.warehouse) {
  791. return
  792. } else {
  793. this.axios
  794. .get("/api/warehouse_stock_number", {
  795. params: {
  796. material_id: row.material_id,
  797. material_detail_id: row.material_detail_id,
  798. },
  799. })
  800. .then((res) => {
  801. this.warehouse= res.data
  802. });
  803. }
  804. // this.warehouse.num = this.warehouseTotal[index].num;
  805. // this.warehouse.warehouseName = this.warehouseTotal[index].warehouseName
  806. },
  807. initData (arrival_no) {
  808. this.axios({
  809. method: 'get',
  810. url: '/api/purchase_arrive_detail',
  811. params: { arrival_no }
  812. }).then((res) => {
  813. this.tableData = res.data.list
  814. const data = JSON.parse(JSON.stringify(res.data))
  815. delete data.list
  816. this.searchData = data
  817. console.log(this.searchData);
  818. this.searchData.arrive_time = this.searchData.arrive_time * 1000 ? new Date(this.searchData.arrive_time * 1000).toLocaleString() : ''
  819. this.searchData.order_time = this.func.replaceDate(this.searchData.order_time);
  820. this.searchData.crt_time = this.func.replaceDate(this.searchData.crt_time)
  821. }).catch((err) => { });
  822. },
  823. postData () {
  824. if(!this.searchData.order_time){
  825. return this.$Message.warning('请选择单据日期')
  826. };
  827. let objData = [];
  828. objData =JSON.parse(JSON.stringify(this.tableData));
  829. if(objData.length == 0){
  830. return this.$Message.warning('请选择物料')
  831. }
  832. let obj = JSON.parse(JSON.stringify(this.searchData))
  833. obj.order_time = new Date(obj.order_time).getTime() / 1000 || ''
  834. obj.arrive_time = new Date(obj.arrive_time).getTime() / 1000|| ''
  835. if (this.$route.query.type == 1) {
  836. // 新增
  837. this.axios({
  838. method: 'post',
  839. url: '/api/purchase_arrive_add ',
  840. data: {
  841. ...obj,
  842. children: this.tableData
  843. }
  844. }).then((res) => {
  845. this.$Message.success(res.msg)
  846. this.goBack()
  847. }).catch((err) => { });
  848. } else {
  849. // 编辑
  850. this.axios({
  851. method: 'post',
  852. url: '/api/purchase_arrive_edit',
  853. data: {
  854. ...obj,
  855. del_list: this.del_list
  856. }
  857. }).then((res) => {
  858. this.$Message.success(res.msg)
  859. this.goBack()
  860. }).catch((err) => { });
  861. }
  862. },
  863. handleReference (type,supply_title) {
  864. this.$reference({
  865. type,
  866. supply_title,
  867. title: '参照采购订单',
  868. then: (result, data) => {
  869. // console.log('result :>> ', result);
  870. // console.log('data :>> ', data);
  871. let id = [];
  872. this.tableData.forEach(v=>{
  873. id.push(v.id)
  874. })
  875. if(this.tableData.length == 0){
  876. this.tableData = result;
  877. this.tableData.forEach(v=>{
  878. v.num = v.arrive_num*1
  879. })
  880. }else{
  881. let content = [];
  882. this.tableData.forEach(v=>{
  883. result.forEach(m=>{
  884. if(v.id==m.id){
  885. console.log(m.arrive_num)
  886. v.num = 1*m.arrive_num
  887. }
  888. })
  889. })
  890. result.forEach(v=>{
  891. if(id.indexOf(v.id)<0){
  892. content.push(v)
  893. }
  894. })
  895. this.tableData.push(...content)
  896. }
  897. let rowTableData = JSON.parse(JSON.stringify(this.tableData));
  898. rowTableData.forEach((element,index)=>{
  899. this.tableData[index].price = 1*element.price.toFixed(2);
  900. this.tableData[index].no_tax_price = (element.price*1/(1+element.tax_rate*1)).toFixed(2);
  901. this.tableData[index].no_tax_total_price = ((element.price*1/(1+element.tax_rate*1))*element.num).toFixed(2);
  902. this.tableData[index].total_price = (element.price*1*element.num).toFixed(2);
  903. this.tableData[index].tax_total_price = (element.price*1*element.num-(element.price*1/(1+element.tax_rate*1))*element.num).toFixed(2);
  904. })
  905. this.searchData.supply_title = result[0].supply_title||'';
  906. this.searchData.supply_id = result[0].supply_id||'';
  907. console.log(result)
  908. console.log(this.tableData)
  909. }
  910. })
  911. },
  912. handleSet (type, row, index) {
  913. this.tableData.splice(index, 1)
  914. this.del_list.push(row.id)
  915. },
  916. handleSelect () {
  917. this.modalData.selectedData.forEach(element => {
  918. element.num = 0
  919. element.no_tax_price = 0
  920. element.fax = 0
  921. element.price = 0
  922. element.no_tax_amount = 0
  923. element.tax_amount = 0
  924. element.total_price = 0
  925. });
  926. this.tableData = [...this.tableData, ...this.modalData.selectedData]
  927. },
  928. changeModalSize (e) {
  929. this.modal_page_size = e;
  930. this.initModal()
  931. },
  932. changeModalPage (e) {
  933. this.modal_page_index = e;
  934. this.initModal()
  935. },
  936. initModal () {
  937. this.axios({
  938. method: 'get',
  939. url: '/api/material_detail_list',
  940. params: {
  941. page_index: this.modal_page_index,
  942. page_size: this.modal_page_size,
  943. title: this.modalData.title
  944. }
  945. }).then((res) => {
  946. this.modal_total = res.data.total
  947. this.modalData.tableData = res.data.data
  948. this.reselection()
  949. }).catch((err) => { });
  950. },
  951. handleTreeSlect (array, row) {
  952. row.id && this.axios({
  953. method: 'get',
  954. url: '/api/material_detail_list',
  955. params: {
  956. page_index: this.modal_page_index,
  957. page_size: this.modal_page_size,
  958. m_id: row.id
  959. }
  960. }).then((res) => {
  961. this.modal_total = res.data.total
  962. this.modalData.tableData = res.data.data
  963. }).catch((err) => { });
  964. },
  965. handleSelection (selection, row) {
  966. this.modalData.selectedData.push(row)
  967. },
  968. handleSelectionCancel (selection, row) {
  969. this.modalData.selectedData.forEach((element, index) => {
  970. if (element.material_detail_id == row.material_detail_id) {
  971. this.modalData.selectedData.splice(index, 1)
  972. }
  973. });
  974. },
  975. handleSelectionAll (selection) {
  976. this.modalData.selectedData = this.modalData.selectedData.concat(selection)
  977. },
  978. handleSelectionAllCancel () {
  979. this.modalData.tableData.forEach(element => {
  980. this.modalData.selectedData = this.modalData.selectedData.filter((x) => {
  981. return x.material_detail_id != element.material_detail_id
  982. })
  983. });
  984. },
  985. reselection () {
  986. this.modalData.selectedData.forEach(element => {
  987. this.modalData.tableData.forEach((ele, idx) => {
  988. if (element.material_detail_id == ele.material_detail_id) {
  989. this.$nextTick(() => {
  990. this.$refs.modelTable.$refs.tbody.objData[idx]._isChecked = true
  991. this.$forceUpdate()
  992. })
  993. }
  994. });
  995. });
  996. },
  997. handleSelectedDele (row, index) {
  998. this.modalData.selectedData.splice(index, 1)
  999. },
  1000. goBack () { this.$router.go(-1) },
  1001. handleProjectSelect () {
  1002. this.searchData.client_name = this.currentChoose.client_name
  1003. },
  1004. handleSupplierSelect () {
  1005. this.searchData.supply_title = this.currentChoose.title
  1006. this.searchData.supply_id = this.currentChoose.id
  1007. // this.tableData.forEach(element => {
  1008. // element.supply_id = this.currentChoose.id
  1009. // });
  1010. },
  1011. changeProjectModalSize (e) {
  1012. this.modal_project_page_size = e
  1013. this.initProjectModal()
  1014. },
  1015. changeProjectModalPage (e) {
  1016. this.modal_project_page_index = e
  1017. this.initProjectModal()
  1018. },
  1019. initProjectModal () {
  1020. this.axios({
  1021. method: 'get',
  1022. url: '/api/order_index',
  1023. params: {
  1024. page_index: this.modal_project_page_index,
  1025. page_size: this.modal_project_page_size,
  1026. title: this.modalProjectData.title
  1027. }
  1028. }).then((res) => {
  1029. this.modal_project_total = res.data.total
  1030. this.modalProjectData.tableData = res.data.data
  1031. }).catch((err) => { });
  1032. },
  1033. changeSupplierModalSize (e) {
  1034. this.modal_supplier_page_size = e
  1035. this.initSupplierModal(this.modalSupplierData)
  1036. },
  1037. changeSupplierModalPage (e) {
  1038. this.modal_supplier_page_index = e
  1039. this.initSupplierModal(this.modalSupplierData)
  1040. },
  1041. initSupplierModal (searchData) {
  1042. this.axios({
  1043. method: 'get',
  1044. url: '/api/supply_list',
  1045. params: {
  1046. page_index: this.modal_supplier_page_index,
  1047. page_size: this.modal_supplier_page_size,
  1048. title: searchData.title,
  1049. code: searchData.code,
  1050. }
  1051. }).then((res) => {
  1052. this.modal_supplier_total = res.data.total
  1053. this.modalSupplierData.tableData = res.data.data
  1054. }).catch((err) => { });
  1055. },
  1056. handleSupplierTreeSlect (arr, row) {
  1057. this.modalSupplierData.code = row.code
  1058. this.initSupplierModal(this.modalSupplierData)
  1059. },
  1060. handleSummary ({ columns, data }) {
  1061. const sums = {};
  1062. columns.forEach((column, index) => {
  1063. const key = column.key;
  1064. if (index == 1) {
  1065. sums[key] = {
  1066. key,
  1067. value: '合计'
  1068. };
  1069. return;
  1070. }
  1071. const values = data.map(item => Number(item[key]));
  1072. if (key == 'num'||key=='no_tax_total_price'||key=='total_price'||key=='tax_total_price') {
  1073. const v = values.reduce((prev, curr) => {
  1074. const value = Number(curr);
  1075. if (!isNaN(value)) {
  1076. return prev + curr;
  1077. } else {
  1078. return prev;
  1079. }
  1080. }, 0);
  1081. sums[key] = {
  1082. key,
  1083. value: v
  1084. };
  1085. } else {
  1086. sums[key] = {
  1087. key,
  1088. value: ' '
  1089. };
  1090. }
  1091. });
  1092. return sums;
  1093. }
  1094. },
  1095. // 监听属性 类似于data概念
  1096. computed: {},
  1097. // 监控data中的数据变化
  1098. watch: {},
  1099. beforeCreate () { }, // 生命周期 - 创建之前
  1100. beforeMount () { }, // 生命周期 - 挂载之前
  1101. beforeUpdate () { }, // 生命周期 - 更新之前
  1102. updated () { }, // 生命周期 - 更新之后
  1103. beforeDestroy () { }, // 生命周期 - 销毁之前
  1104. destroyed () { }, // 生命周期 - 销毁完成
  1105. activated () { }, // 如果页面有keep-alive缓存功能,这个函数会触发
  1106. }
  1107. </script>
  1108. <style lang='scss' scoped>
  1109. .content_topform {
  1110. padding-top: 20px;
  1111. /deep/.ivu-form {
  1112. display: flex;
  1113. justify-content: flex-start;
  1114. align-items: flex-start;
  1115. flex-wrap: wrap;
  1116. }
  1117. /deep/.ivu-form-item {
  1118. display: inline-block;
  1119. width: 300px;
  1120. }
  1121. }
  1122. .content_table {
  1123. .content_table_btn {
  1124. display: flex;
  1125. justify-content: space-between;
  1126. align-items: center;
  1127. padding-bottom: 20px;
  1128. }
  1129. .content_table_btn_right {
  1130. display: flex;
  1131. justify-content: flex-start;
  1132. align-items: center;
  1133. }
  1134. }
  1135. .modal_content {
  1136. display: flex;
  1137. justify-content: center;
  1138. overflow: hidden;
  1139. overflow-y: auto;
  1140. .modal_content_left {
  1141. }
  1142. .modal_content_center {
  1143. width: 80%;
  1144. border-left: 1px solid #666;
  1145. border-right: 1px solid #666;
  1146. padding: 0 20px;
  1147. .modal_content_center_top {
  1148. display: flex;
  1149. justify-content: flex-start;
  1150. align-items: center;
  1151. span {
  1152. width: 100px;
  1153. }
  1154. div {
  1155. display: flex;
  1156. justify-content: space-around;
  1157. align-items: center;
  1158. span {
  1159. width: 100px;
  1160. }
  1161. }
  1162. .modal_content_center_body {
  1163. overflow: hidden;
  1164. overflow-y: auto;
  1165. height: 500px;
  1166. }
  1167. }
  1168. .modal_content_center_body {
  1169. padding-top: 20px;
  1170. }
  1171. .modal_content_center_footer {
  1172. display: flex;
  1173. justify-content: center;
  1174. padding-top: 20px;
  1175. }
  1176. }
  1177. .modal_content_right {
  1178. width: 30%;
  1179. padding: 0 20px;
  1180. }
  1181. }
  1182. /deep/ .ivu-table-wrapper {
  1183. overflow: visible;
  1184. } //穿透iview
  1185. /deep/.order_time .ivu-form-item-label:before {
  1186. content: '*';
  1187. display: inline-block;
  1188. margin-right: 4px;
  1189. line-height: 1;
  1190. font-family: SimSun;
  1191. font-size: 14px;
  1192. color: #ed4014;
  1193. }
  1194. </style>