edit.vue 39 KB

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