edit.vue 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698
  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. >参照采购计划</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="120"
  24. :model="searchData">
  25. <FormItem label="订单号:" :label-width='80'>
  26. <Input type="text"
  27. size="small"
  28. v-show="!isCheck"
  29. disabled
  30. v-model="searchData.order_no"
  31. style="width: 200px;margin-top:6px"
  32. placeholder="自动生成订单号">
  33. </Input>
  34. <span v-show="isCheck">{{searchData.order_no}}</span>
  35. </FormItem>
  36. <!-- <FormItem label="项目名称:">
  37. <Input type="text"
  38. size="small"
  39. v-show="!isCheck"
  40. v-model="searchData.residential_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. <span v-show="isCheck">{{searchData.residential_name}}</span>
  48. </FormItem> -->
  49. <FormItem label="供应商名称:">
  50. <Input type="text"
  51. size="small"
  52. v-show="!isCheck"
  53. v-model="searchData.supply_title"
  54. style="width: 300px;margin-top:6px"
  55. placeholder="供应商名称">
  56. <span slot="append"
  57. style="cursor:pointer;"
  58. @click="showSupplierModal=true">选择</span>
  59. </Input>
  60. <span v-show="isCheck">{{searchData.supply_title}}</span>
  61. </FormItem>
  62. <FormItem label="采购订单类型:" style="margin-left:100px">
  63. <Select v-model="searchData.basics_purchase_id"
  64. size="small"
  65. v-show="!isCheck"
  66. clearable
  67. filterable
  68. label-in-value
  69. style="width: 200px">
  70. <Option v-for="(sitem) in purchaseTypeList"
  71. :key="sitem.id"
  72. :label="sitem.title"
  73. :value="sitem.id">
  74. </Option>
  75. </Select>
  76. <span v-show="isCheck">{{searchData.basics_purchase_title}}</span>
  77. </FormItem>
  78. <!-- <FormItem label="单据号:">
  79. <Input type="text"
  80. size="small"
  81. v-show="!isCheck"
  82. readonly
  83. v-model="searchData.purchase_order_no"
  84. style="width: 200px"
  85. placeholder="自动生成" />
  86. <span v-show="isCheck">{{searchData.purchase_order_no}}</span>
  87. </FormItem> -->
  88. <!-- <FormItem label="制单人:"
  89. v-show="isCheck"> -->
  90. <!-- <Select v-model="searchData.nickname"
  91. size="small"
  92. v-show="!isCheck"
  93. clearable
  94. filterable
  95. label-in-value
  96. style="width: 200px">
  97. <Option v-for="(sitem) in usersList"
  98. :key="sitem.nickname"
  99. :label="sitem.nickname"
  100. :value="sitem.nickname">
  101. </Option>
  102. </Select> -->
  103. <!-- <span>{{searchData.nickname}}</span>
  104. </FormItem> -->
  105. <FormItem label="单据日期:">
  106. <DatePicker type="date"
  107. v-show="!isCheck"
  108. size="small"
  109. style="width: 200px"
  110. placeholder="年/月/日"
  111. v-model="searchData.order_time"></DatePicker>
  112. <span v-show="isCheck">{{searchData.order_time?func.replaceDate(searchData.order_time).split(' ')[0]:''}}</span>
  113. </FormItem>
  114. <FormItem label="预计到货日期:" style="margin-left:30px">
  115. <DatePicker type="date"
  116. v-show="!isCheck"
  117. size="small"
  118. style="width: 200px"
  119. placeholder="年/月/日"
  120. v-model="searchData.arrive_time"></DatePicker>
  121. <span v-show="isCheck">{{searchData.arrive_time?func.replaceDate(searchData.arrive_time).split(' ')[0]:''}}</span>
  122. </FormItem>
  123. <FormItem label="备注:" :label-width='80'>
  124. <Input type="textarea"
  125. v-show="!isCheck"
  126. size="small"
  127. v-model="searchData.remark"
  128. style="width: 200px"
  129. placeholder="备注" />
  130. <span v-show="isCheck">{{searchData.remark}}</span>
  131. </FormItem>
  132. </Form>
  133. </div>
  134. <div class="content_table">
  135. <div class="content_table_btn">
  136. <div style="display:flex;">
  137. <span style="width:200px">采购清单</span>
  138. <!-- <Button @click="showModal=true"
  139. v-show="!isCheck"
  140. type="primary"
  141. size="small"
  142. style="margin-left:10px;"
  143. :disabled="$route.query.is_refer == 0?true:btn_disable">选择物料</Button> -->
  144. <div ><span>参照计划单号:</span><span v-for="(item,index) in plan_no" :key="index" style="margin-right:10px">{{item}}{{index+1==plan_no.length?'':','}}</span></div>
  145. </div>
  146. <div class="content_table_btn_right"
  147. v-show="!isCheck">
  148. <Dropdown trigger="click" style="margin-left: 20px" @on-click='DropDownSort' >
  149. <a href="javascript:void(0)">
  150. 批量修改
  151. <Icon type="ios-arrow-down"></Icon>
  152. </a>
  153. <DropdownMenu slot="list" >
  154. <DropdownItem :name='2'>数量</DropdownItem>
  155. <DropdownItem :name='3'>税率</DropdownItem>
  156. <DropdownItem :name='1'>项目信息</DropdownItem>
  157. </DropdownMenu>
  158. </Dropdown>
  159. </div>
  160. </div>
  161. <Table :columns="tableColumns"
  162. border
  163. :data="tableData"
  164. :max-height='500'
  165. show-summary
  166. :summary-method="handleSummary"
  167. @on-selection-change='selectRow' >
  168. <template slot="material_sort" slot-scope="{ row,index }">
  169. <span v-if="row.material_title == '选择物料'"></span>
  170. <div v-else>
  171. <span >{{ tableData[index].material_type }}</span></div>
  172. </template>
  173. <template slot="material_title" slot-scope="{ row,index }">
  174. <span
  175. v-show="!isCheck"
  176. style="cursor: pointer;color:#2d8cf0"
  177. @click="showModal = true"
  178. >
  179. {{tableData[index].material_title}}
  180. </span>
  181. <span v-show="isCheck">{{ row.material_title }}</span>
  182. </template>
  183. <template slot="project_number" slot-scope="{row}">
  184. <span @click="check(row)" style="color: rgb(45, 140, 240);cursor: pointer;">{{row.project_number}}</span>
  185. </template>
  186. <template slot="project_code" slot-scope="{ row,index }">
  187. <span v-if="row.material_title == '选择物料'"></span>
  188. <div v-else>
  189. <Select
  190. v-model="tableData[index].project_code"
  191. size="small"
  192. clearable
  193. transfer
  194. v-show="!isCheck&&row.project_number!=='查看'"
  195. @on-change='selectChange(row,index)'
  196. filterable
  197. label-in-value
  198. >
  199. <Option
  200. v-for="(sitem,index) in project_number"
  201. :key="index"
  202. :label="sitem"
  203. :value="sitem"
  204. >
  205. </Option>
  206. </Select>
  207. <span v-show="isCheck||row.project_number == '查看'" @click="check(row)" style="color: rgb(45, 140, 240);cursor: pointer;">{{row.project_number=='查看'?'查看':row.project_code}}</span>
  208. </div>
  209. </template>
  210. <template slot="project_title" slot-scope="{ row,index }">
  211. <span v-if="row.material_title == '选择物料'"></span>
  212. <div v-else>
  213. <Select
  214. v-model="tableData[index].project_title"
  215. size="small"
  216. clearable
  217. transfer
  218. @on-change='selectChange(row,index)'
  219. v-show="!isCheck&&row.project_number!=='查看'"
  220. filterable
  221. label-in-value
  222. >
  223. <Option
  224. v-for="(sitem,index) in project_name"
  225. :key="index"
  226. :label="sitem"
  227. :value="sitem"
  228. >
  229. </Option>
  230. </Select>
  231. <span v-show="isCheck||row.project_number == '查看'" @click="check(row)" style="color: rgb(45, 140, 240);cursor: pointer;">{{row.project_number=='查看'?'查看':row.project_title}}</span>
  232. </div>
  233. </template>
  234. <template slot="numberSet" slot-scope="{row , index }">
  235. <span v-if="row.material_title == '选择物料'"></span>
  236. <div v-else>
  237. <Tooltip
  238. placement="left"
  239. @on-popper-show="handleToolShow(index, row)"
  240. >
  241. <div slot="content">
  242. <div>
  243. <div v-for="(_item,_index) in warehouse" :key="_index">
  244. {{_item.warehouse_title}}:{{_item.num}}
  245. </div>
  246. </div>
  247. </div>
  248. <Input
  249. v-show="!isCheck"
  250. size="small"
  251. v-model="tableData[index].num"
  252. placeholder="数量"
  253. @on-change="changenum($event,row,index)"
  254. :disabled="row.project_number == '查看'"
  255. >
  256. </Input>
  257. <span v-show="isCheck">{{ tableData[index].num }}</span>
  258. </Tooltip>
  259. </div>
  260. </template>
  261. <template slot="setSlot"
  262. slot-scope="{row,index}">
  263. <span v-if="row.material_title == '选择物料'"></span>
  264. <div v-else>
  265. <a style="margin:0 5px"
  266. v-show="!isCheck"
  267. :disabled="row.state==0"
  268. @click="handleSet(3,row,index)"
  269. >复制</a>
  270. <a style="margin:0 5px"
  271. v-show="!isCheck"
  272. :disabled="row.state==0"
  273. @click="handleSet(4,row,index)">删除</a>
  274. </div>
  275. </template>
  276. </Table>
  277. </div>
  278. <Modal v-model="showModal"
  279. title="选择物料"
  280. width='80'
  281. @on-ok="handleSelect"
  282. @on-cancel="showModal=false">
  283. <div class="modal_content">
  284. <div class="modal_content_left">
  285. <Tree :data="modalData.treeData"
  286. children-key='list'
  287. style="width:100%;"
  288. @on-select-change="handleTreeSlect"
  289. class="demo-tree-render"></Tree>
  290. </div>
  291. <div class="modal_content_center">
  292. <div class="modal_content_center_top">
  293. <div><span>物料名称:</span>
  294. <Input type="text"
  295. v-model="modalData.title"
  296. placeholder="请输入物料名称" />
  297. </div>
  298. <Button @click="initModal()"
  299. type="primary"
  300. style="margin:0 10px;">搜索</Button>
  301. </div>
  302. <div class="modal_content_center_body">
  303. <Table :columns="modalTableColumns"
  304. height="520"
  305. border
  306. ref="modelTable"
  307. @on-select-all="handleSelectionAll"
  308. @on-select-all-cancel="handleSelectionAllCancel"
  309. @on-select="handleSelection"
  310. @on-select-cancel="handleSelectionCancel"
  311. :loading="modalTableLoading"
  312. :data="modalData.tableData">
  313. </Table>
  314. <div class="modal_content_center_footer">
  315. <Page :page-size-opts="[10, 20, 30, 40,100]"
  316. @on-page-size-change='changeModalSize'
  317. @on-change='changeModalPage'
  318. :current='modal_page_index'
  319. show-total
  320. :total="modal_total"
  321. show-sizer
  322. :page-size='modal_page_size' />
  323. </div>
  324. </div>
  325. </div>
  326. <div class="modal_content_right">
  327. <span>已选</span>
  328. <Table :columns="selectedColumns"
  329. max-height="500"
  330. border
  331. :data="modalData.selectedData">
  332. <template slot="selectedSetSlot"
  333. slot-scope="{row,index}">
  334. <a style="margin:0 5px;color:red"
  335. @click="handleSelectedDele(row,index)">删除</a>
  336. </template>
  337. </Table>
  338. </div>
  339. </div>
  340. </Modal>
  341. <Modal v-model="showProjectModal"
  342. title="选择项目"
  343. width='80'
  344. @on-ok="handleProjectSelect"
  345. @on-cancel="showProjectModal=false">
  346. <div class="modal_content">
  347. <div class="modal_content_center">
  348. <div class="modal_content_center_top">
  349. <span>项目名称:</span>
  350. <Input type="text"
  351. v-model="modalProjectData.title"
  352. style="width:180px"
  353. placeholder="请输入物料名称" />
  354. <Button @click="initProjectModal()"
  355. type="primary"
  356. style="margin:0 10px;">搜索</Button>
  357. </div>
  358. <div class="modal_content_center_body">
  359. <Table :columns="modalProjectTableColumns"
  360. height="520"
  361. border
  362. :loading="modalProjectTableLoading"
  363. :data="modalProjectData.tableData">
  364. <template slot="basicTypeSet"
  365. slot-scope="{row}">
  366. <div>
  367. <span v-for="item in warningList"
  368. :key="item.id"
  369. :style="{color:item.color}"
  370. v-show="item.id==row.warning_state">{{item.title}}</span>
  371. </div>
  372. </template>
  373. </Table>
  374. <div class="modal_content_center_footer">
  375. <Page :page-size-opts="[10, 20, 30, 40,100]"
  376. @on-page-size-change='changeProjectModalSize'
  377. @on-change='changeProjectModalPage'
  378. :current='modal_project_page_index'
  379. show-total
  380. :total="modal_project_total"
  381. show-sizer
  382. :page-size='modal_project_page_size' />
  383. </div>
  384. </div>
  385. </div>
  386. </div>
  387. </Modal>
  388. <Modal v-model="showSupplierModal"
  389. title="选择供应商"
  390. width='80'
  391. @on-ok="handleSupplierSelect"
  392. @on-cancel="showSupplierModal=false">
  393. <div class="modal_content">
  394. <div class="modal_content_left">
  395. <Tree :data="modalSupplierData.treeData"
  396. children-key='sub'
  397. style="width:100%;"
  398. @on-select-change="handleSupplierTreeSlect"
  399. class="demo-tree-render"></Tree>
  400. </div>
  401. <div class="modal_content_center">
  402. <div class="modal_content_center_top">
  403. <span>供应商名称:</span>
  404. <Input type="text"
  405. v-model="modalSupplierData.title"
  406. style="width:180px"
  407. placeholder="请输入供应商名称" />
  408. <Button @click="initSupplierModal(modalSupplierData)"
  409. type="primary"
  410. style="margin:0 10px;">搜索</Button>
  411. </div>
  412. <div class="modal_content_center_body">
  413. <Table :columns="modalSupplierTableColumns"
  414. height="520"
  415. border
  416. :loading="modalSupplierTableLoading"
  417. :data="modalSupplierData.tableData">
  418. </Table>
  419. <div class="modal_content_center_footer">
  420. <Page :page-size-opts="[10, 20, 30, 40,100]"
  421. @on-page-size-change='changeSupplierModalSize'
  422. @on-change='changeSupplierModalPage'
  423. :current='modal_supplier_page_index'
  424. show-total
  425. :total="modal_supplier_total"
  426. show-sizer
  427. :page-size='modal_supplier_page_size' />
  428. </div>
  429. </div>
  430. </div>
  431. </div>
  432. </Modal>
  433. <Modal
  434. :width='400'
  435. v-model="showTotal"
  436. @on-ok='total_sure'
  437. :title="total_type==1?'批量修改项目信息':total_type==2?'批量修改数量':'批量修改税率'">
  438. <div style="text-align:center">
  439. <div v-if="total_type==1">
  440. <Form>
  441. <FormItem>
  442. <span>项目编码 : </span>
  443. <Select v-model="total_project_info.code" style="width:200px">
  444. <Option v-for="(item,index) in project_number" :value="item" :key="index">{{ item }}</Option>
  445. </Select>
  446. </FormItem>
  447. <FormItem>
  448. <span>项目名称 : </span>
  449. <Select v-model="total_project_info.name" style="width:200px">
  450. <Option v-for="(item,index) in project_name" :value="item" :key="index">{{ item }}</Option>
  451. </Select>
  452. </FormItem>
  453. </Form>
  454. </div>
  455. <div v-if="total_type==2">
  456. <span>数量 : </span><Input v-model="total_num" style="width:50%" type="number"/>
  457. </div>
  458. <div v-if="total_type == 3">
  459. <span>税率一键修改 : </span>
  460. <Input v-model="total_fax" style="width:50%" type="number"/>%
  461. </div>
  462. </div>
  463. </Modal>
  464. <Modal
  465. :width='800'
  466. v-model="showCheck"
  467. title="查看">
  468. <span>物料名称:{{material_name}}</span>
  469. <Table
  470. :columns="CheckTableColumns"
  471. :max-height="520"
  472. border
  473. :data='checkData'
  474. style='margin-top:10px'
  475. >
  476. </Table>
  477. </Modal>
  478. </div>
  479. </template>
  480. <script>
  481. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  482. // 例如:import 《组件名称》 from '《组件路径》';
  483. export default {
  484. name: '',
  485. components: {
  486. },
  487. props: {},
  488. // import引入的组件需要注入到对象中才能使用
  489. data () {
  490. // 这里存放数据
  491. return {
  492. delData:[],
  493. material_name:'',
  494. checkData:[],
  495. CheckTableColumns:[
  496. { title: '计划单号', key: 'plan_no', align: 'center', minWidth: 150},
  497. { title: '采购计划类型', key: 'plan_type_title', align: 'center', minWidth: 100},
  498. { title: '项目编码', key: 'project_code', align: 'center', minWidth: 150},
  499. { title: '项目名称', key: 'project_name', align: 'center', minWidth: 150},
  500. { title: '数量', key: 'purchases_num', align: 'center', minWidth: 100}
  501. ],
  502. showCheck:false,
  503. selectChoose:[],
  504. total_fax:0,
  505. project_name:[],
  506. project_number:[],
  507. total_num:'',
  508. total_project_info:{
  509. code:'',
  510. name:""
  511. },
  512. total_type:'',
  513. showTotal:false,
  514. btn_disable:false,
  515. fax_modify: '',
  516. searchData: {
  517. residential_name: ''
  518. },
  519. purchaseTypeList: [],
  520. modalProjectData: {
  521. title: '',
  522. tableData: [{}]
  523. },
  524. table_state:'',
  525. modalSupplierData: {
  526. title: '',
  527. code: '',
  528. treeData: [
  529. {
  530. title: '供应商分类',
  531. expand: true,
  532. sub: [],
  533. render: (h, { root, node, data }) => {
  534. return h('span', {
  535. style: {
  536. display: 'inline-block',
  537. width: '100%'
  538. }
  539. }, [
  540. h('span', [
  541. h('Icon', {
  542. props: {
  543. type: 'ios-folder-outline'
  544. },
  545. style: {
  546. marginRight: '8px'
  547. }
  548. }),
  549. h('span', data.title)
  550. ]),
  551. h('span', {
  552. style: {
  553. display: 'inline-block',
  554. // float: 'right',
  555. marginRight: '32px'
  556. }
  557. })
  558. ]);
  559. },
  560. }
  561. ],
  562. tableData: [{}]
  563. },
  564. tableColumns: [
  565. {key: 'select', align: 'center', minWidth: 80,type:'selection'},
  566. { title: '物料分类', key: 'type_title', align: 'center', minWidth: 140,slot:'material_sort'},
  567. { title: '物料名称', key: 'material_title', align: 'center', minWidth: 140 ,slot:'material_title'},
  568. {
  569. title: '物料规格', key: 'model', align: 'center', minWidth: 140,
  570. render: (h, params) => {
  571. const { row } = params
  572. let text = `${row.long ? row.long : 0}*${row.width ? row.width : 0}*${row.high ? row.high : 0}`
  573. if(row.material_title =='选择物料'){
  574. return h('span',{},'')
  575. }else{
  576. return h('span', {}, text)
  577. }
  578. }
  579. },
  580. { title: '计量单位', key: 'unit', align: 'center', minWidth: 100 },
  581. {
  582. title: '数量', key: 'num', align: 'center', minWidth: 120,slot:"numberSet"
  583. // render: (h, params) => {
  584. // const { row, index } = params
  585. // const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  586. // return this.isCheck ? h('span', {}, currentRow.num) : h('Input', {
  587. // props: {
  588. // value: currentRow.num,
  589. // type: 'text'
  590. // },
  591. // on: {
  592. // 'on-change': (e) => {
  593. // currentRow.num = e.target.value
  594. // currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  595. // currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  596. // currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  597. // this.tableData.splice(index, 1, currentRow);
  598. // }
  599. // }
  600. // })
  601. // }
  602. },
  603. {
  604. title: '无税单价', key: 'no_tax_price', align: 'center', minWidth: 120,
  605. render: (h, params) => {
  606. const { row, index } = params
  607. const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  608. if(row.material_title==='选择物料'){
  609. return h('span',{},'')
  610. }else{
  611. return this.isCheck ? h('span', {}, currentRow.no_tax_price) : h('Input', {
  612. props: {
  613. value: currentRow.no_tax_price,
  614. type: 'text'
  615. },
  616. on: {
  617. 'on-change': (e) => {
  618. currentRow.no_tax_price = e.target.value
  619. currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  620. currentRow.price = (1 * currentRow.no_tax_price * (1 + 1 * currentRow.fax / 100)).toFixed(2)
  621. currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  622. currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  623. if(!currentRow.copy&&!currentRow.edit){
  624. currentRow.change = true;
  625. }
  626. // currentRow.total_price = (1 * currentRow.no_tax_amount + 1 * currentRow.tax_amount).toFixed(2)
  627. this.tableData.splice(index, 1, currentRow);
  628. }
  629. }
  630. })
  631. }
  632. }
  633. },
  634. {
  635. title: '税率', key: 'fax', align: 'center', minWidth: 120,
  636. render: (h, params) => {
  637. const { row, index } = params
  638. const currentRow = this.tableData[index]
  639. if(row.material_title === '选择物料' ){
  640. return h('span',{},'')
  641. }else{
  642. return this.isCheck ? h('span', {}, currentRow.fax) : h('Input', {
  643. props: {
  644. value: currentRow.fax,
  645. type: 'text',
  646. },
  647. on: {
  648. 'on-change': (e) => {
  649. currentRow.fax = e.target.value
  650. currentRow.price = (1 * currentRow.no_tax_price * (1 + 1 * currentRow.fax / 100)).toFixed(2)
  651. currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  652. currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  653. if(!currentRow.copy&&!currentRow.edit){
  654. currentRow.change = true;
  655. }
  656. this.tableData.splice(index, 1, currentRow);
  657. }
  658. }
  659. }, [h('span', { slot: 'append' }, '%')])
  660. }
  661. }
  662. },
  663. {
  664. title: '含税单价', key: 'price', align: 'center', minWidth: 120,
  665. render: (h, params) => {
  666. const { row, index } = params
  667. const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  668. if(row.material_title === '选择物料' ){
  669. return h('span',{},'')
  670. }else{
  671. return this.isCheck ? h('span', {}, currentRow.price) : h('Input', {
  672. props: {
  673. value: currentRow.price,
  674. type: 'text'
  675. },
  676. on: {
  677. 'on-change': (e) => {
  678. currentRow.price = e.target.value
  679. currentRow.no_tax_price = (1 * currentRow.price / (1 + 1 * currentRow.fax / 100)).toFixed(2)
  680. currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  681. currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  682. currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  683. if(!currentRow.copy&&!currentRow.edit){
  684. currentRow.change = true;
  685. }
  686. this.tableData.splice(index, 1, currentRow);
  687. }
  688. }
  689. })
  690. }
  691. }
  692. },
  693. {
  694. title: '无税金额', key: 'no_tax_amount', align: 'center', minWidth: 120,
  695. render: (h, params) => {
  696. const { row, index } = params
  697. const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  698. if(row.material_title === '选择物料' ){
  699. return h('span',{},'')
  700. }else{
  701. return this.isCheck ? h('span', {}, currentRow.no_tax_amount) : h('Input', {
  702. props: {
  703. value: currentRow.no_tax_amount,
  704. type: 'text'
  705. },
  706. on: {
  707. 'on-change': (e) => {
  708. currentRow.no_tax_amount = e.target.value
  709. currentRow.no_tax_price = (1 * currentRow.no_tax_amount / 1*currentRow.num).toFixed(2)
  710. currentRow.price = (1 * currentRow.no_tax_price * (1 + 1 * currentRow.fax / 100)).toFixed(2)
  711. currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  712. currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  713. if(!currentRow.copy&&!currentRow.edit){
  714. currentRow.change = true;
  715. }
  716. this.tableData.splice(index, 1, currentRow);
  717. }
  718. }
  719. })
  720. }
  721. }
  722. },
  723. {
  724. title: '税额', key: 'tax_amount', align: 'center', minWidth: 120,
  725. render: (h, params) => {
  726. const { row, index } = params
  727. const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  728. if(row.material_title === '选择物料' ){
  729. return h('span',{},'')
  730. }else{
  731. return this.isCheck ? h('span', {}, currentRow.tax_amount) : h('Input', {
  732. props: {
  733. value: currentRow.tax_amount,
  734. type: 'text',
  735. },
  736. on: {
  737. 'on-change': (e) => {
  738. currentRow.tax_amount = e.target.value
  739. // currentRow.fax = (1 * currentRow.tax_amount / currentRow.no_tax_price).toFixed(2)
  740. currentRow.no_tax_amount = (1*(currentRow.total_price-currentRow.tax_amount)).toFixed(2)
  741. currentRow.no_tax_price = (1*(currentRow.no_tax_amount/currentRow.num)).toFixed(2)
  742. if(!currentRow.copy&&!currentRow.edit){
  743. currentRow.change = true;
  744. }
  745. this.tableData.splice(index, 1, currentRow);
  746. }
  747. }
  748. })
  749. }
  750. }
  751. },
  752. {
  753. title: '价格合计', key: 'total_price', align: 'center', minWidth: 120,
  754. render: (h, params) => {
  755. const { row, index } = params
  756. const currentRow = JSON.parse(JSON.stringify(this.tableData[index]))
  757. if(row.material_title === '选择物料' ){
  758. return h('span',{},'')
  759. }else{
  760. return this.isCheck ? h('span', {}, currentRow.total_price) : h('Input', {
  761. props: {
  762. value: currentRow.total_price,
  763. type: 'text',
  764. },
  765. on: {
  766. 'on-change': (e) => {
  767. currentRow.total_price = e.target.value
  768. currentRow.price = (1 * currentRow.total_price / currentRow.num).toFixed(2)
  769. currentRow.no_tax_price = (1 * currentRow.price / (1 + 1 * currentRow.fax / 100)).toFixed(2)
  770. currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  771. currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  772. if(!currentRow.copy&&!currentRow.edit){
  773. currentRow.change = true;
  774. }
  775. this.tableData.splice(index, 1, currentRow);
  776. }
  777. }
  778. })
  779. }
  780. }
  781. },
  782. { title: '参照计划单号', key: 'project_number', align: 'center', minWidth: 100,slot:'project_number' },
  783. { title: '项目编码', key: 'project_code', align: 'center', minWidth: 100,slot: "project_code" },
  784. { title: '项目名称', key: 'project_title', align: 'center', minWidth: 100,slot: "project_title" },
  785. { title: '操作', key: 'code', align: 'center', minWidth: 120, slot: 'setSlot' },
  786. ],
  787. tableData: [{material_title:'选择物料',_disabled:true}],
  788. showModal: false,
  789. showProjectModal: false,
  790. showSupplierModal: false,
  791. modalTableLoading: false,
  792. modalProjectTableLoading: false,
  793. modalSupplierTableLoading: false,
  794. modal_project_page_index: 1,
  795. modal_project_page_size: 10,
  796. modal_project_total: 0,
  797. modal_supplier_page_index: 1,
  798. modal_supplier_page_size: 10,
  799. modal_supplier_total: 0,
  800. currentChoose: {},
  801. warehouse:'',
  802. modalProjectTableColumns: [
  803. {
  804. title: '选择', key: '', align: 'center', minWidth: 60,
  805. render: (h, params) => {
  806. let id = params.row.id;
  807. let flag = false;
  808. if (this.currentChoose.id == id) {
  809. flag = true
  810. } else {
  811. flag = false
  812. }
  813. let self = this
  814. return h('div', [
  815. h('Radio', {
  816. props: {
  817. value: flag
  818. },
  819. on: {
  820. 'on-change': () => {
  821. self.currentChoose = params.row;
  822. }
  823. }
  824. })
  825. ])
  826. }
  827. },
  828. { title: '项目名称', key: 'residential_name', align: 'center', minWidth: 100 },
  829. { title: '紧急程度', align: 'center', key: 'warning_state', minWidth: 80, slot: 'basicTypeSet', },
  830. {
  831. title: '创建时间', key: 'crt_time', align: 'center', minWidth: 110,
  832. render: (h, params) => {
  833. const { row } = params
  834. return h('span', {}, this.func.replaceDate(row.crt_time))
  835. }
  836. },
  837. ],
  838. modalSupplierTableColumns: [
  839. {
  840. title: '选择', key: '', align: 'center', minWidth: 60,
  841. render: (h, params) => {
  842. let id = params.row.id;
  843. let flag = false;
  844. if (this.currentChoose.id == id) {
  845. flag = true
  846. } else {
  847. flag = false
  848. }
  849. let self = this
  850. return h('div', [
  851. h('Radio', {
  852. props: {
  853. value: flag
  854. },
  855. on: {
  856. 'on-change': () => {
  857. self.currentChoose = params.row;
  858. }
  859. }
  860. })
  861. ])
  862. }
  863. },
  864. { title: '供应商编码', key: 'code', align: 'center', minWidth: 100 },
  865. { title: '供应商名称', key: 'title', align: 'center', minWidth: 80, },
  866. { title: '负责人', key: 'contact', align: 'center', minWidth: 110, },
  867. { title: '联系方式', key: 'mobile', align: 'center', minWidth: 110, },
  868. ],
  869. modalData: {
  870. title: '',
  871. tableData: [{}],
  872. selectedData: [],
  873. treeData: [
  874. {
  875. title: '物料分类',
  876. expand: true,
  877. list: [],
  878. render: (h, { root, node, data }) => {
  879. return h('span', {
  880. style: {
  881. display: 'inline-block',
  882. width: '100%'
  883. }
  884. }, [
  885. h('span', [
  886. h('Icon', {
  887. props: {
  888. type: 'ios-folder-outline'
  889. },
  890. style: {
  891. marginRight: '8px'
  892. }
  893. }),
  894. h('span', data.title)
  895. ]),
  896. h('span', {
  897. style: {
  898. display: 'inline-block',
  899. // float: 'right',
  900. marginRight: '32px'
  901. }
  902. })
  903. ]);
  904. },
  905. }
  906. ],
  907. },
  908. selectedColumns: [
  909. { title: '物料名称', key: 'title', align: 'center', minWidth: 110 },
  910. { title: '操作', key: 'title', align: 'center', minWidth: 90, slot: 'selectedSetSlot' },
  911. ],
  912. modal_page_index: 1,
  913. modal_page_size: 10,
  914. modal_total: 0,
  915. modalTableColumns: [
  916. { title: '全选', type: 'selection', align: 'center', minWidth: 60 },
  917. { title: '物料名称', key: 'title', align: 'center', minWidth: 110 },
  918. { title: '物料规格', key: 'model', align: 'center', minWidth: 110 },
  919. { title: '计量单位', key: 'unit', align: 'center', minWidth: 110 },
  920. ],
  921. usersList: [],
  922. isCheck: false,
  923. warningList: [],
  924. purchase_data:[],
  925. purchase_tableData:[],
  926. plan_no:[],
  927. }
  928. },
  929. // 生命周期 - 创建完成(可以访问当前this实例)
  930. created () {
  931. this.$route.query.type == 2 ? this.isCheck = true : this.isCheck = false
  932. // 获取操作员
  933. this.axios('/api/user').then(res => this.usersList = res.data.data)
  934. // 获取采购类型
  935. this.axios({ method: 'get', url: '/api/basic_purchase_list',params:{type_id:2} }).then((res) => { this.purchaseTypeList = res.data.data }).catch((err) => { });
  936. // 获取基础物料类型
  937. this.axios({ method: 'get', url: '/api/basics_material_index_level', }).then((res) => { this.modalData.treeData[0].list = res.data }).catch((err) => { });
  938. // 获取供应商列表
  939. this.axios({ method: 'get', url: '/api/supply_list', }).then((res) => { this.suppliersList = res.data.data }).catch((err) => { });
  940. // 获取供应商分类
  941. this.axios({ method: 'get', url: '/api/basic_supply_list', }).then((res) => { this.modalSupplierData.treeData[0].sub = res.data }).catch((err) => { });
  942. // //获取项目列表
  943. this.axios({ method: 'get', url: '/api/purchase_orders_list', }).then((res) => {
  944. this.project_name = res.data.project_name;
  945. this.project_number = res.data.project_number;
  946. }).catch((err) => { });
  947. // // 获取项目列表
  948. // this.axios({ method: 'get', url: '/api/order_index', }).then((res) => {
  949. // this.modalProjectData.tableData = res.data.data
  950. // this.modal_project_total = res.data.total
  951. // console.log(res);
  952. // }).catch((err) => { });
  953. // 获取紧急程度
  954. this.axios.get('/api/warning_list').then(res => { this.warningList = res.data.data })
  955. this.initModal()
  956. this.initProjectModal()
  957. this.initSupplierModal(this.modalSupplierData)
  958. },
  959. // 生命周期 - 挂载完成(可以访问DOM元素)
  960. mounted () {
  961. if (this.$route.query.order_no != '') {
  962. this.initData(this.$route.query.order_no)
  963. }
  964. },
  965. methods: {
  966. selectChange(row,index){
  967. if(!row.copy&&!row.edit){
  968. this.tableData[index].change = true;
  969. console.log(this.tableData)
  970. }
  971. },
  972. check(row){
  973. console.log(row);
  974. if(row.project_number!=='查看'){
  975. return
  976. }else{
  977. let data=[];
  978. this.purchase_data.forEach(v=>{
  979. if(row.material_detail_id == v[0].material_detail_id){
  980. v.forEach(m=>{
  981. let obj ={};
  982. obj.plan_no = m.plan_no;
  983. obj.plan_type_title=m.plan_type_title;
  984. obj.project_code = m.project_code;
  985. obj.project_name=m.project_title;
  986. obj.purchases_num = m.purchases_num;
  987. data.push(obj)
  988. })
  989. }
  990. })
  991. this.material_name = row.material_title;
  992. this.checkData = data;
  993. this.showCheck = true;
  994. }
  995. },
  996. selectRow(e){
  997. this.selectChoose = e;
  998. },
  999. total_sure(){
  1000. //1项目信息 2数量 3税率
  1001. switch(this.total_type){
  1002. case 1:
  1003. this.tableData.map((v)=>{
  1004. if(v.project_number == '查看'){
  1005. return
  1006. }else{
  1007. this.selectChoose.map(m=>{
  1008. if(m.index == v.index ){
  1009. v.project_code =this.total_project_info.code?this.total_project_info.code:v.project_code;
  1010. v.project_title = this.total_project_info.name?this.total_project_info.name:v.project_title;
  1011. v._checked = true;
  1012. v.ad = true
  1013. }
  1014. })
  1015. }
  1016. })
  1017. break;
  1018. case 2:
  1019. this.tableData.map((v)=>{
  1020. this.selectChoose.map(m=>{
  1021. if(m.index == v.index ){
  1022. v.num =this.total_num;
  1023. v._checked = true;
  1024. v.ad = true
  1025. }
  1026. })})
  1027. break;
  1028. case 3:
  1029. this.tableData.map((v)=>{
  1030. this.selectChoose.map(m=>{
  1031. if(m.index == v.index ){
  1032. v.fax =this.total_fax;
  1033. v._checked = true;
  1034. v.ad = true
  1035. }
  1036. })})
  1037. break;
  1038. }
  1039. },
  1040. handleSummary({ columns, data }){
  1041. const sums = {};
  1042. columns.forEach((column, index) => {
  1043. const key = column.key;
  1044. if (index === 1) {
  1045. sums[key] = {
  1046. key,
  1047. value: '合计'
  1048. };
  1049. return;
  1050. }
  1051. const values = data.map(item => Number(item[key]));
  1052. if (key == 'num'||key=='no_tax_amount'||key=='total_price'||key=='tax_amount') {
  1053. let v = values.reduce((prev, curr) => {
  1054. const value = Number(curr);
  1055. if (!isNaN(value)) {
  1056. return prev + curr;
  1057. } else {
  1058. return prev;
  1059. }
  1060. }, 0);
  1061. // this.table_total_num = Number(JSON.parse(JSON.stringify(v)));
  1062. sums[key] = {
  1063. key,
  1064. value:v
  1065. };
  1066. } else {
  1067. sums[key] = {
  1068. key,
  1069. value: ''
  1070. };
  1071. }
  1072. });
  1073. return sums;
  1074. },
  1075. DropDownSort(val){
  1076. if(this.selectChoose.length == 0){
  1077. return this.$Message.warning('请先选择物料')
  1078. }
  1079. this.showTotal = true;
  1080. this.total_type = val;
  1081. },
  1082. changenum(e,currentRow,index){
  1083. console.log(currentRow)
  1084. currentRow.num = e.target.value
  1085. currentRow.total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  1086. this.tableData[index].total_price = (1 * currentRow.price * currentRow.num).toFixed(2)
  1087. currentRow.no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  1088. this.tableData[index].no_tax_amount = (1 * currentRow.no_tax_price * currentRow.num).toFixed(2)
  1089. currentRow.tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  1090. this.tableData[index].tax_amount = (1 * currentRow.total_price - 1 * currentRow.no_tax_amount).toFixed(2)
  1091. if(!this.tableData[index].copy&&!this.tableData[index].edit){
  1092. this.tableData[index].change = true;
  1093. }
  1094. },
  1095. handleToolShow(index, row) {
  1096. if (this.warehouse) {
  1097. return
  1098. } else {
  1099. this.axios
  1100. .get("/api/warehouse_stock_number", {
  1101. params: {
  1102. material_id: row.material_id,
  1103. material_detail_id: row.material_detail_id,
  1104. },
  1105. })
  1106. .then((res) => {
  1107. this.warehouse= res.data
  1108. });
  1109. }
  1110. // this.warehouse.num = this.warehouseTotal[index].num;
  1111. // this.warehouse.warehouseName = this.warehouseTotal[index].warehouseName
  1112. },
  1113. initData (order_no) {
  1114. this.axios({
  1115. method: 'get',
  1116. url: '/api/purchase_detail',
  1117. params: { order_no }
  1118. }).then((res) => {
  1119. if(this.$route.query.type==2){
  1120. this.tableData = []
  1121. }
  1122. this.tableData=res.data.list;
  1123. const data = JSON.parse(JSON.stringify(res.data))
  1124. delete data.list
  1125. this.searchData = data
  1126. this.searchData.crt_time = this.func.replaceDate(this.searchData.crt_time)
  1127. this.searchData.arrive_time = this.func.replaceDate(this.searchData.arrive_time)
  1128. this.searchData.order_time = this.func.replaceDate(this.searchData.order_time)
  1129. this.searchData.supply_id = this.tableData[0].supply_id || null
  1130. this.tableData.forEach(element => {
  1131. if(element.state==1){
  1132. element.project_number = '查看'
  1133. }
  1134. element.material_type = element.type_title;
  1135. element.material_title = element.title;
  1136. element.fax = 1*element.tax_rate*100;
  1137. element.no_tax_price = (1 * element.price / (1 + 1*element.tax_rate)).toFixed(2)
  1138. element.no_tax_amount = (1 * element.no_tax_price * element.num).toFixed(2)
  1139. element.total_price = (1 * element.price * element.num).toFixed(2)
  1140. element.tax_amount = (1 * element.total_price - 1 * element.no_tax_amount).toFixed(2)
  1141. });
  1142. if(this.$route.query.type!==2){
  1143. this.tableData.push({material_title:'选择物料',_disabled:true})
  1144. }
  1145. console.log(this.tableData)
  1146. }).catch((err) => { });
  1147. },
  1148. postData () {
  1149. if(!this.searchData.order_time){
  1150. return this.$Message.warning('请选择单据日期')
  1151. };
  1152. let obj = JSON.parse(JSON.stringify(this.searchData))
  1153. obj.order_time = parseInt(new Date(obj.order_time).getTime() / 1000) || ''
  1154. obj.arrive_time = parseInt(new Date(obj.arrive_time).getTime() / 1000) || ''
  1155. // if(this.tableData == null){
  1156. // this.confirmDelete({
  1157. // content: '请选择物料',
  1158. // title:'提示',
  1159. // type: 'error',
  1160. // then: () => {
  1161. // // this.select_post(n, this.selectIds)
  1162. // },
  1163. // cancel: () => { }
  1164. // })
  1165. // }
  1166. if (this.$route.query.type == 1||this.$route.query.type == 6) {
  1167. // 新增
  1168. let children=[];
  1169. this.tableData.forEach(v=>{
  1170. let obj={};
  1171. obj.material_id=v.material_id;
  1172. obj.material_detail_id = v.material_detail_id ;
  1173. obj.project_code = v.project_code;
  1174. obj.project_title = v.project_title ;
  1175. obj.num = v.num;
  1176. obj.price = v.price;
  1177. obj.tax_rate = (1*v.fax)/100;
  1178. if(v.project_number == '查看'){
  1179. obj.state = 1
  1180. }else{
  1181. obj.state =0
  1182. };
  1183. this.purchase_data.forEach(m=>{
  1184. if(v.material_detail_id = m[0].material_detail_id){
  1185. obj.children=[...m]
  1186. }
  1187. })
  1188. children.push(obj)
  1189. })
  1190. children.pop();
  1191. this.axios({
  1192. method: 'post',
  1193. url: '/api/purchase_add',
  1194. data: {
  1195. ...obj,
  1196. children
  1197. }
  1198. }).then((res) => {
  1199. if (res.code == 200) {
  1200. this.$Message.success(res.msg)
  1201. this.goBack()
  1202. }
  1203. }).catch((err) => { });
  1204. } else {
  1205. let objData = [];
  1206. objData =JSON.parse(JSON.stringify(this.tableData));
  1207. objData.pop();
  1208. let upd_list = [];
  1209. let add_list = [];
  1210. let del_list = this.delData;
  1211. objData.forEach(v=>{
  1212. if(v.edit||v.copy){
  1213. add_list.push(v)
  1214. }
  1215. if(v.change||v.ad){
  1216. if(!v.edit||!v.copy){
  1217. upd_list.push(v)
  1218. }
  1219. }
  1220. })
  1221. // 编辑
  1222. this.axios({
  1223. method: 'post',
  1224. url: '/api/purchase_edit',
  1225. data: {
  1226. order_no: this.$route.query.order_no,
  1227. ...obj,
  1228. upd_list,
  1229. add_list,
  1230. del_list
  1231. }
  1232. }).then((res) => {
  1233. if (res.code == 200) {
  1234. this.$Message.success(res.msg)
  1235. this.goBack()
  1236. }
  1237. }).catch((err) => { });
  1238. }
  1239. },
  1240. handleReference (type) {
  1241. this.$reference({
  1242. type,
  1243. title: '参照采购计划',
  1244. then: (result, data) => {
  1245. result.forEach(element => {
  1246. element.num = 0
  1247. element.no_tax_price = 0
  1248. element.fax = 0
  1249. element.price = 0
  1250. element.no_tax_amount = 0
  1251. element.tax_amount = 0
  1252. element.total_price = 0
  1253. // element.type_title = element.m_title
  1254. // element.material_id = element.m_id
  1255. element.supply_id = this.searchData.supply_id
  1256. this.table_state = 1
  1257. });
  1258. let obj = {},newArr = [];
  1259. result.forEach((item,suffix)=>{
  1260. if(!obj[item.material_detail_id]){
  1261. let arr =[];
  1262. arr.push(item);
  1263. newArr.push(arr);
  1264. obj[item.material_detail_id]=item;
  1265. }else{
  1266. newArr.forEach((v,index)=>{
  1267. if(v[0].material_detail_id == item.material_detail_id){
  1268. v.push(item)
  1269. }
  1270. })
  1271. }
  1272. })
  1273. let copy_purchase_data = JSON.parse(JSON.stringify(this.purchase_data));
  1274. let title = [];
  1275. copy_purchase_data.forEach(m=>{
  1276. if(title.indexOf(m[0].material_detail_id)<0){
  1277. title.push(m[0].material_detail_id);
  1278. }
  1279. })
  1280. let content = [];
  1281. newArr.forEach(v=>{
  1282. if(copy_purchase_data.length==0){
  1283. this.purchase_data.push(v)
  1284. }else{
  1285. this.purchase_data.forEach((m,index)=>{
  1286. let id=[];
  1287. let m_content=[];
  1288. let val =copy_purchase_data[index];
  1289. val.forEach(s=>{
  1290. id.push(s.id)
  1291. })
  1292. if(v[0].material_detail_id == m[0].material_detail_id){
  1293. m.forEach(mm=>{
  1294. v.forEach(vv=>{
  1295. if(mm.id == vv.id){
  1296. mm.purchases_num = 1*vv.purchases_num+1*mm.purchases_num
  1297. }
  1298. if(id.indexOf(vv.id)<0){
  1299. m_content.push(vv)
  1300. }
  1301. })
  1302. })
  1303. m.push(...m_content)
  1304. }
  1305. })
  1306. if(title.indexOf(v[0].material_detail_id)<0){
  1307. content.push(v)
  1308. }
  1309. }
  1310. })
  1311. this.purchase_data.push(...content);
  1312. this.purchase_tableData = [];
  1313. this.purchase_data.forEach(v=>{
  1314. let data = {...v[0]};
  1315. data.num = 0
  1316. data.no_tax_price = 0
  1317. data.fax = 0
  1318. data.price = 0
  1319. data.no_tax_amount = 0
  1320. data.tax_amount = 0
  1321. data.total_price = 0
  1322. data.project_number = '查看'
  1323. data.project_code = '查看'
  1324. data.project_title = '查看'
  1325. v.forEach(m=>{
  1326. data.num+=m.purchases_num*1;
  1327. })
  1328. this.purchase_tableData.push(data)
  1329. })
  1330. console.log(this.purchase_tableData);
  1331. this.plan_no = [];
  1332. this.purchase_data.forEach(v=>{
  1333. v.forEach(m=>{
  1334. if(this.plan_no.indexOf(m.plan_no)<0){
  1335. this.plan_no.push(m.plan_no)
  1336. }
  1337. })
  1338. })
  1339. this.tableData = [{material_title:'选择物料',_disabled:true}];
  1340. this.tableData.unshift(...this.purchase_tableData,...this.modalData.selectedData)
  1341. // this.searchData.residential_name = result[0].residential_name
  1342. // console.log(result)
  1343. }
  1344. })
  1345. },
  1346. handleModify () {
  1347. this.tableData.forEach(element => {
  1348. this.handleModifyTaxRate(element)
  1349. });
  1350. },
  1351. handleSet (type, row, index) {
  1352. if(type==3){
  1353. if(row.project_number == '查看'){
  1354. let obj = JSON.parse(JSON.stringify(row));
  1355. obj.project_number = '';
  1356. obj.id=obj.id+''+'a';
  1357. // console.log(row);
  1358. // console.log(obj)
  1359. this.tableData.splice(index+1,0,obj)
  1360. this.modalData.selectedData.push(obj)
  1361. row.copy=true;
  1362. // console.log(this.tableData)
  1363. }else{
  1364. this.tableData.splice(index+1,0,row);
  1365. this.modalData.selectedData.push(row)
  1366. row.copy=true;
  1367. }
  1368. }else if(type == 4){
  1369. if(!row.copy&&!row.edit){
  1370. this.delData.push(row.id)
  1371. }
  1372. this.tableData.splice(index, 1);
  1373. this.purchase_data.forEach((v,idx)=>{
  1374. if(row.material_detail_id == v[0].material_detail_id){
  1375. this.purchase_data.splice(idx,1)
  1376. }
  1377. })
  1378. this.modalData.selectedData.forEach((m,idx)=>{
  1379. if(row.id === m.id){
  1380. this.modalData.selectedData.splice(idx,1)
  1381. }
  1382. })
  1383. }else{
  1384. return
  1385. }
  1386. },
  1387. handleSelect () {
  1388. this.modalData.selectedData.forEach(element => {
  1389. element.edit = true;
  1390. element.material_title = element.title
  1391. element.num = 0
  1392. element.no_tax_price = 0
  1393. element.fax = 0
  1394. element.price = 0
  1395. element.no_tax_amount = 0
  1396. element.tax_amount = 0
  1397. element.total_price = 0
  1398. element.material_type = element.m_title
  1399. element.material_id = element.m_id
  1400. element.supply_id = this.searchData.supply_id
  1401. element.project_code =null;
  1402. element.project_title=null;
  1403. });
  1404. // console.log(this.modalData.selectedData);
  1405. this.tableData.splice(this.tableData.length-1,0,...JSON.parse(JSON.stringify(this.modalData.selectedData)))
  1406. this.table_state = 0
  1407. this.tableData.map((item,index)=>{
  1408. item.residential_name = this.currentChoose.residential_name
  1409. this.tableData.splice(index,1,item) });
  1410. this.tableData.map((m,index)=>{
  1411. m.index = index
  1412. })
  1413. },
  1414. changeModalSize (e) {
  1415. this.modal_page_size = e;
  1416. this.initModal()
  1417. },
  1418. changeModalPage (e) {
  1419. this.modal_page_index = e;
  1420. this.initModal()
  1421. },
  1422. initModal () {
  1423. this.axios({
  1424. method: 'get',
  1425. url: '/api/material_detail_list',
  1426. params: {
  1427. page_index: this.modal_page_index,
  1428. page_size: this.modal_page_size,
  1429. title: this.modalData.title
  1430. }
  1431. }).then((res) => {
  1432. this.modal_total = res.data.total
  1433. this.modalData.tableData = res.data.data
  1434. this.reselection()
  1435. }).catch((err) => { });
  1436. },
  1437. reselection () {
  1438. this.modalData.selectedData.forEach(element => {
  1439. this.modalData.tableData.forEach((ele, idx) => {
  1440. if (element.material_detail_id == ele.material_detail_id) {
  1441. this.$nextTick(() => {
  1442. this.$refs.modelTable.$refs.tbody.objData[idx]._isChecked = true
  1443. this.$forceUpdate()
  1444. })
  1445. }
  1446. });
  1447. });
  1448. },
  1449. handleSelection (selection, row) {
  1450. this.modalData.selectedData.push(row)
  1451. },
  1452. handleSelectedDele (row, index) {
  1453. this.modalData.selectedData.splice(index, 1)
  1454. },
  1455. goBack () { this.$router.go(-1) },
  1456. handleProjectSelect () {
  1457. this.searchData.residential_name = this.currentChoose.residential_name
  1458. this.searchData.order_no = this.currentChoose.order_no
  1459. this.tableData.map((item,index)=>{
  1460. item.residential_name = this.currentChoose.residential_name
  1461. this.tableData.splice(index,1,item)
  1462. })
  1463. },
  1464. handleSupplierSelect () {
  1465. this.searchData.supply_title = this.currentChoose.title
  1466. this.searchData.supply_id = this.currentChoose.id
  1467. this.tableData.forEach(element => {
  1468. element.supply_id = this.currentChoose.id
  1469. });
  1470. },
  1471. changeProjectModalSize (e) {
  1472. this.modal_project_page_size = e
  1473. this.initProjectModal()
  1474. },
  1475. changeProjectModalPage (e) {
  1476. this.modal_project_page_index = e
  1477. this.initProjectModal()
  1478. },
  1479. initProjectModal () {
  1480. this.axios({
  1481. method: 'get',
  1482. url: '/api/order_index',
  1483. params: {
  1484. page_index: this.modal_project_page_index,
  1485. page_size: this.modal_project_page_size,
  1486. title: this.modalProjectData.title
  1487. }
  1488. }).then((res) => {
  1489. this.modal_project_total = res.data.total
  1490. this.modalProjectData.tableData = res.data.data
  1491. }).catch((err) => { });
  1492. },
  1493. changeSupplierModalSize (e) {
  1494. this.modal_supplier_page_size = e
  1495. this.initSupplierModal(this.modalSupplierData)
  1496. },
  1497. changeSupplierModalPage (e) {
  1498. this.modal_supplier_page_index = e
  1499. this.initSupplierModal(this.modalSupplierData)
  1500. },
  1501. initSupplierModal (searchData) {
  1502. this.axios({
  1503. method: 'get',
  1504. url: '/api/supply_list',
  1505. params: {
  1506. page_index: this.modal_supplier_page_index,
  1507. page_size: this.modal_supplier_page_size,
  1508. title: searchData.title,
  1509. code: searchData.code,
  1510. }
  1511. }).then((res) => {
  1512. this.modal_supplier_total = res.data.total
  1513. this.modalSupplierData.tableData = res.data.data
  1514. }).catch((err) => { });
  1515. },
  1516. handleSupplierTreeSlect (arr, row) {
  1517. this.modalSupplierData.code = row.code
  1518. this.initSupplierModal(this.modalSupplierData)
  1519. },
  1520. handleModifyTaxRate (row) {
  1521. // this.$nextTick(() => {
  1522. row.fax = this.fax_modify * 1
  1523. row.price = (1 * row.no_tax_price * (1 + 1 * row.fax / 100)).toFixed(2)
  1524. row.total_price = (1 * row.price * row.num).toFixed(2)
  1525. row.tax_amount = (1 * row.total_price - 1 * row.no_tax_amount).toFixed(2)
  1526. // this.$forceUpdate()
  1527. // })
  1528. },
  1529. handleTreeSlect (array, row) {
  1530. row.id && this.axios({
  1531. method: 'get',
  1532. url: '/api/material_detail_list',
  1533. params: {
  1534. page_index: this.modal_page_index,
  1535. page_size: this.modal_page_size,
  1536. m_id: row.id
  1537. }
  1538. }).then((res) => {
  1539. this.modal_total = res.data.total
  1540. this.modalData.tableData = res.data.data
  1541. }).catch((err) => { });
  1542. },
  1543. handleSelectionAll (selection) {
  1544. this.modalData.selectedData = this.modalData.selectedData.concat(selection)
  1545. },
  1546. handleSelectionAllCancel () {
  1547. this.modalData.tableData.forEach(element => {
  1548. this.modalData.selectedData = this.modalData.selectedData.filter((x) => {
  1549. return x.material_detail_id != element.material_detail_id
  1550. })
  1551. });
  1552. },
  1553. handleSelectionCancel (selection, row) {
  1554. this.modalData.selectedData.forEach((element, index) => {
  1555. if (element.material_detail_id == row.material_detail_id) {
  1556. this.modalData.selectedData.splice(index, 1)
  1557. }
  1558. });
  1559. },
  1560. },
  1561. // 监听属性 类似于data概念
  1562. computed: {},
  1563. // 监控data中的数据变化
  1564. watch: {},
  1565. beforeCreate () { }, // 生命周期 - 创建之前
  1566. beforeMount () { }, // 生命周期 - 挂载之前
  1567. beforeUpdate () { }, // 生命周期 - 更新之前
  1568. updated () { }, // 生命周期 - 更新之后
  1569. beforeDestroy () { }, // 生命周期 - 销毁之前
  1570. destroyed () { }, // 生命周期 - 销毁完成
  1571. activated () { }, // 如果页面有keep-alive缓存功能,这个函数会触发
  1572. }
  1573. </script>
  1574. <style lang='scss' scoped>
  1575. .content_topform {
  1576. padding-top: 20px;
  1577. /deep/.ivu-form {
  1578. display: flex;
  1579. justify-content: flex-start;
  1580. align-items: flex-start;
  1581. flex-wrap: wrap;
  1582. }
  1583. /deep/.ivu-form-item {
  1584. display: inline-block;
  1585. width: 300px;
  1586. }
  1587. }
  1588. .content_table {
  1589. .content_table_btn {
  1590. display: flex;
  1591. justify-content: space-between;
  1592. align-items: center;
  1593. padding-bottom: 20px;
  1594. }
  1595. .content_table_btn_right {
  1596. display: flex;
  1597. justify-content: flex-start;
  1598. align-items: center;
  1599. }
  1600. }
  1601. .modal_content {
  1602. display: flex;
  1603. justify-content: center;
  1604. overflow: hidden;
  1605. overflow-y: auto;
  1606. .modal_content_left {
  1607. }
  1608. .modal_content_center {
  1609. width: 80%;
  1610. border-left: 1px solid #666;
  1611. border-right: 1px solid #666;
  1612. padding: 0 20px;
  1613. .modal_content_center_top {
  1614. display: flex;
  1615. justify-content: flex-start;
  1616. align-items: center;
  1617. span {
  1618. width: 100px;
  1619. }
  1620. div {
  1621. display: flex;
  1622. justify-content: space-around;
  1623. align-items: center;
  1624. span {
  1625. width: 100px;
  1626. }
  1627. }
  1628. .modal_content_center_body {
  1629. overflow: hidden;
  1630. overflow-y: auto;
  1631. height: 500px;
  1632. }
  1633. }
  1634. .modal_content_center_body {
  1635. padding-top: 20px;
  1636. }
  1637. .modal_content_center_footer {
  1638. display: flex;
  1639. justify-content: center;
  1640. padding-top: 20px;
  1641. }
  1642. }
  1643. .modal_content_right {
  1644. width: 30%;
  1645. padding: 0 20px;
  1646. }
  1647. }
  1648. /deep/ .ivu-table-wrapper {
  1649. overflow: visible;
  1650. } //穿透iview
  1651. /deep/ .ivu-checkbox-disabled{
  1652. display: none!important;
  1653. }
  1654. </style>