toolList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <div>
  3. <!-- <add-product ref="addpro" :data="data" @onConfirm="listData"></add-product>-->
  4. <addTool ref="addTool" :params="paramsAdd" :tablecolsAdd="tablecolsAdd" title="添加" @addSuccess="addTools"
  5. @addProduct="addTool" @uploadData="uploadData" @closeDrawer="listData();$emit('onSuccess')"
  6. class="inline-16 normal-margin" v-if="data.status === '新建'"
  7. ></addTool>
  8. <uploadAllData
  9. v-if="data.status === '新建'"
  10. class="inline-16 normal-margin"
  11. :total="total"
  12. @onSuccess="listData();$emit('onSuccess')"
  13. @handlePullApi="handlePullApi"
  14. @handleDelApi="handleDelApi"
  15. idName="sa_orderitemsid"
  16. type="del"
  17. ></uploadAllData>
  18. <excel style="margin:0 0 10px 10px" :tablecols="columnTitle" :param="param" :total="total" :excelTitle="excelTitle"></excel>
  19. <el-table
  20. ref="multipleTable"
  21. :data="tableData"
  22. height="500px"
  23. style="width: 100%;"
  24. size="small"
  25. stripe
  26. border>
  27. <el-table-column
  28. prop="itemname"
  29. label="产品名称"
  30. fixed
  31. width="180">
  32. </el-table-column>
  33. <el-table-column
  34. prop="itemno"
  35. label="产品编号"
  36. width="180">
  37. </el-table-column>
  38. <el-table-column
  39. label="型号"
  40. width="150"
  41. prop="model">
  42. <template slot-scope="scope">
  43. <p><span>{{scope.row.model}}</span></p>
  44. </template>
  45. </el-table-column>
  46. <el-table-column
  47. label="规格"
  48. width="150"
  49. prop="spec">
  50. <template slot-scope="scope">
  51. <p><span>{{scope.row.spec}}</span></p>
  52. </template>
  53. </el-table-column>
  54. <el-table-column
  55. label="数量"
  56. width="180"
  57. prop="qty">
  58. <template slot-scope="scope">
  59. <el-input-number :controls="true" controls-position='right' :step-strictly="true" v-if="type === 'edit' && !data.sa_contractid" size="mini" v-model="scope.row.qty" :min="scope.row.orderminqty" :step="scope.row.orderaddqty" label="输入数量" @change="rowChange(scope.row,scope.$index)"></el-input-number>
  60. <span v-else>{{scope.row.qty}}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column
  64. prop="needdate"
  65. label="需求日期"
  66. width="180">
  67. <template slot="header" slot-scope="scope">
  68. <div>
  69. <el-date-picker
  70. style="width:150px"
  71. v-if="type === 'edit'"
  72. v-model="value2"
  73. value-format="yyyy-MM-dd"
  74. slot="reference"
  75. align="right"
  76. type="date"
  77. size="mini"
  78. placeholder="一键交期"
  79. @change="dateChangeNeed">
  80. </el-date-picker>
  81. <span v-else>需求日期</span>
  82. </div>
  83. </template>
  84. <template slot-scope="scope">
  85. <el-date-picker
  86. v-if="scope.row.delivery > 0 && type === 'edit'"
  87. v-model="scope.row.needdate"
  88. type="date"
  89. placeholder="选择日期"
  90. value-format="yyyy-MM-dd"
  91. size="mini"
  92. style="width:150px"
  93. :picker-options="pickerOptions"
  94. @change="rowChange(scope.row)"
  95. @focus="setPickerOptions(scope.row)">
  96. </el-date-picker>
  97. <div v-else>
  98. <p v-if="scope.row.delivery === 0 ">不管控交期</p>
  99. <p v-else>{{scope.row.needdate}}</p>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. label="回复交期"
  105. width="200"
  106. prop="deliverydate">
  107. <template slot="header" slot-scope="scope">
  108. <div>
  109. <el-date-picker
  110. style="width:180px"
  111. v-if="type === 'confirmdate'"
  112. v-model="value2"
  113. value-format="yyyy-MM-dd"
  114. slot="reference"
  115. align="right"
  116. type="date"
  117. size="mini"
  118. placeholder="一键交期"
  119. @change="dateChange">
  120. </el-date-picker>
  121. <span v-else>回复交期</span>
  122. </div>
  123. </template>
  124. <template slot-scope="scope">
  125. <el-date-picker
  126. v-if="scope.row.delivery > 0 && type === 'confirmdate'"
  127. v-model="scope.row.deliverydate"
  128. type="date"
  129. placeholder="选择日期"
  130. value-format="yyyy-MM-dd"
  131. size="mini"
  132. style="width:150px"
  133. :picker-options="pickerOptions"
  134. @change="onDateChange(scope.row)"
  135. @focus="setPickerOptions(scope.row)">
  136. </el-date-picker>
  137. <div v-else>
  138. <p v-if="scope.row.delivery === 0 ">不管控交期</p>
  139. <p v-else>{{scope.row.deliverydate}}</p>
  140. </div>
  141. </template>
  142. </el-table-column>
  143. <el-table-column
  144. prop="unit"
  145. label="计量单位"
  146. width="90">
  147. <template slot-scope="scope">
  148. <el-tag size="mini" type="info" effect="plain">{{scope.row.unit}}</el-tag>
  149. </template>
  150. </el-table-column>
  151. <el-table-column
  152. prop="price"
  153. label="价格"
  154. width="100">
  155. <template slot-scope="scope">
  156. <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.price,2)}}</p>
  157. </template>
  158. </el-table-column>
  159. <el-table-column
  160. label="小计"
  161. prop="deliverydate">
  162. <template slot-scope="scope">
  163. <p style="color:red;font-weight:500">¥&nbsp;{{tool.formatAmount(scope.row.price * scope.row.qty,2)}}</p>
  164. </template>
  165. </el-table-column>
  166. <el-table-column
  167. label="备注"
  168. width="300"
  169. prop="remarks">
  170. <template slot-scope="scope">
  171. <el-input v-if="type === 'edit'" v-model="scope.row.remarks" placeholder="输入订单备注" size="mini" @change="rowChange(scope.row,scope.$index)"></el-input>
  172. <p v-else>{{scope.row.remarks}}</p>
  173. </template>
  174. </el-table-column>
  175. <el-table-column v-if="!data.sa_contractid" width="90" fixed="right">
  176. <template slot-scope="scope">
  177. <el-button v-if="tool.checkAuth($route.name,'billDetail')" type="text" size="mini" @click="deleteOrderProduct(scope.row)">删 除</el-button>
  178. </template>
  179. </el-table-column>
  180. </el-table>
  181. <div style="margin-top:16px;text-align:right">
  182. <el-pagination
  183. background
  184. small
  185. @size-change="handleSizeChange"
  186. @current-change="handleCurrentChange"
  187. :current-page="currentPage"
  188. :page-size="param.content.pageSize"
  189. layout="total, prev, pager, next, jumper"
  190. :total="total">
  191. </el-pagination>
  192. </div>
  193. </div>
  194. </template>
  195. <script>
  196. import addProduct from '@/template/toolBorrowingCanUseProduct/index.vue'
  197. import addTool from '@/template/addTool/index'
  198. import uploadAllData from '@/components/uploadAllData/index'
  199. import excel from '@/HDrpManagement/orderManage/details/export_excel'
  200. export default {
  201. props:['data','type'],
  202. data () {
  203. return {
  204. dataRefresh:true,
  205. tableData:[],
  206. tablecolsAdd:[],
  207. columnTitle:[],
  208. excelTitle:'借用单明细',
  209. param:{
  210. "id": 20230116104102,
  211. "content": {
  212. "sa_orderid": 0, //订单ID
  213. "pageNumber": 1,
  214. "pageSize": 20,
  215. "where": {
  216. "condition": ""
  217. }
  218. },
  219. },
  220. paramsAdd:{
  221. "id": 20230116111602,
  222. "content": {
  223. "sa_orderid": this.$route.query.id,
  224. "pageNumber": 1,
  225. "pageSize": 100,
  226. "where": {
  227. "condition": ""
  228. }
  229. },
  230. },
  231. pickerOptions: {
  232. disabledDate(time) {
  233. return time.getTime() < (Date.now() - 24 * 3600 * 1000);
  234. },
  235. },
  236. total:0,
  237. currentPage:0,
  238. time: null,
  239. value2:''
  240. }
  241. },
  242. components:{
  243. addProduct,addTool,uploadAllData,excel
  244. },
  245. methods:{
  246. async listData () {
  247. this.param.content.sa_orderid = this.$route.query.id
  248. const res = await this.$api.requested(this.param)
  249. this.tableData = res.data
  250. this.total = res.total
  251. this.currentPage = res.pageNumber
  252. this.$emit('queryDetail')
  253. },
  254. handleSizeChange(val) {
  255. // console.log(`每页 ${val} 条`);
  256. this.params.content.pageSize = val
  257. this.listData()
  258. },
  259. handleCurrentChange(val) {
  260. // console.log(`当前页: ${val}`);
  261. this.params.content.pageNumber = val
  262. this.listData()
  263. },
  264. async deleteOrderProduct (row) {
  265. const res = await this.$api.requested({
  266. "id": 20221109093702,
  267. "content": {
  268. "sa_orderid":this.$route.query.id,
  269. "sa_orderitemsids": [row.sa_orderitemsid]
  270. },
  271. })
  272. this.tool.showMessage(res,()=>{
  273. this.listData()
  274. this.$emit('onSuccess')
  275. })
  276. },
  277. rowChange (val,index) {
  278. let that = this
  279. this.$set(this.tableData,index,val)
  280. // // 防抖
  281. if(this.time !== null){
  282. clearTimeout(this.time);
  283. }
  284. this.time = setTimeout(() => {
  285. that.updateOrder({
  286. "sa_orderid": this.data.sa_orderid, //订单ID
  287. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  288. "sa_contractid": this.data.contacts.contactsid, //合同ID
  289. "type": this.data.type, //订单类型
  290. "items": [{
  291. "sa_orderitemsid": val.sa_orderitemsid,//0表示新增
  292. "itemid": val.itemid, //商品ID
  293. "qty": val.qty, //数量
  294. "needdate": val.needdate,//可以不传,修改交期
  295. "price":val.price,
  296. "remarks":val.remarks
  297. }]
  298. })
  299. },500)
  300. },
  301. onDateChange (val){
  302. let that = this
  303. that.updateOrder({
  304. "sa_orderid": this.data.sa_orderid, //订单ID
  305. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  306. "sa_contractid": this.data.contacts.contactsid, //合同ID
  307. "type": this.data.type, //订单类型
  308. "items": [{
  309. "sa_orderitemsid": val.sa_orderitemsid,//0表示新增
  310. "itemid": val.itemid, //商品ID
  311. "qty": val.qty, //数量
  312. "deliverydate": val.deliverydate//可以不传,修改交期
  313. }]
  314. })
  315. },
  316. async dateChangeNeed(val){
  317. // const res = await this.$api.requested({
  318. // "id": 20230104143802,
  319. // "content": {
  320. // "sa_orderid": this.data.sa_orderid,
  321. // "needdate": this.value2
  322. // },
  323. // })
  324. },
  325. async updateOrder (val) {
  326. const res = await this.$api.requested({
  327. "id": 20230116101602,
  328. "content": val
  329. })
  330. this.$emit('onSuccess')
  331. },
  332. setPickerOptions (val) {
  333. var startDate = val.deliverydate
  334. startDate = startDate.replace(new RegExp("-","gm"),"/")
  335. var startDateM = (new Date(startDate)).getTime()
  336. this.pickerOptions = {
  337. disabledDate(time) {
  338. return time.getTime() < startDateM;
  339. },
  340. }
  341. },
  342. async dateChange (row) {
  343. this.tableData = this.tableData.filter(e=>{
  344. if (e.delivery > 0) {
  345. e.deliverydate = this.value2
  346. }
  347. return e
  348. })
  349. const res = await this.$api.requested({
  350. "id": 20230104143102,
  351. "content": {
  352. "sa_orderid": this.$route.query.id,
  353. "deliverydate": this.value2
  354. },
  355. })
  356. },
  357. /*批量添加工具*/
  358. async addTools(data){
  359. let item = data.map(item => {
  360. return {
  361. sa_orderitemsid:0,
  362. itemid:item.itemid,
  363. qty:item.orderminqty,
  364. needdate:item.deliverydate
  365. }
  366. })
  367. let res = await this.$api.requested({
  368. "id": 20221109093602,
  369. "content": {
  370. "sa_orderid": this.$route.query.id, //订单ID
  371. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  372. "type": "工具借用单", //订单类型
  373. "items": item
  374. },
  375. })
  376. this.tool.showMessage(res,() => {
  377. this.listData()
  378. this.$refs.addTool.listData()
  379. this.$emit('onSuccess')
  380. })
  381. },
  382. /*单独添加*/
  383. async addTool(data){
  384. let res = await this.$api.requested({
  385. "id": 20221109093602,
  386. "content": {
  387. "sa_orderid": this.$route.query.id, //订单ID
  388. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  389. "type": "工具借用单", //订单类型
  390. "items": [
  391. {
  392. sa_orderitemsid:0,
  393. itemid:data.itemid,
  394. qty:data.orderminqty,
  395. needdate:data.deliverydate
  396. }
  397. ]
  398. },
  399. })
  400. this.tool.showMessage(res,() => {
  401. this.listData()
  402. this.$refs.addTool.listData()
  403. this.$emit('onSuccess')
  404. })
  405. },
  406. /*一键添加*/
  407. uploadData (uploadApi,data) {
  408. uploadApi.id = 20221109093602
  409. uploadApi.content = {
  410. "sa_orderid": this.$route.query.id, //订单ID
  411. "sys_enterpriseid": this.data.sys_enterpriseid, //企业ID
  412. "type": "工具借用单", //订单类型
  413. "items": data.map(e=>{
  414. return {
  415. sa_orderitemsid:0,
  416. itemid:e.itemid,
  417. qty:e.orderminqty,
  418. needdate:e.deliverydate
  419. }
  420. })
  421. }
  422. this.listData()
  423. this.$refs.addTool.listData()
  424. this.$emit('onSuccess')
  425. },
  426. /*拉取数据*/
  427. handlePullApi (pullApi) {
  428. pullApi.content = JSON.parse(JSON.stringify(this.param.content))
  429. pullApi.id = 20230116104102
  430. pullApi.content.sa_orderid = this.$route.query.id
  431. },
  432. /*一键删除*/
  433. handleDelApi (delApi,data) {
  434. delApi.id = 20221109093702
  435. delApi.content = {
  436. "sa_orderid":this.$route.query.id,
  437. "sa_orderitemsids": data,
  438. "pageNumber":0,
  439. "pageSize":0
  440. }
  441. this.listData()
  442. },
  443. },
  444. mounted () {
  445. this.listData()
  446. this.columnTitle = []
  447. this.$refs.multipleTable.$children.forEach(obj => {
  448. let columnChild = {'columnname':obj.prop,'filter':0,'rowindex':'','sequence':'','title':obj.label,'width':obj.width}
  449. // 存到columnTitle数组中
  450. this.columnTitle.push(columnChild)
  451. })
  452. },
  453. created() {
  454. this.tablecolsAdd = this.tool.tabelCol(this.$route.name).addToolTable.tablecols
  455. }
  456. }
  457. </script>
  458. <style>
  459. </style>