edit.vue 40 KB

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