Advertisement
vitareinforce

InventoryList.vue

Sep 22nd, 2021
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.74 KB | None | 0 0
  1. <template>
  2. <div v-if="userData.RoleDetails.IsReadInventory" class="dashboard-contents">
  3. <div class="row">
  4. <div class="col-lg-4" style="margin-top: 20px;">
  5. <h2 style="padding:15px; margin-top:10px;">Daftar Inventory</h2>
  6. </div>
  7.  
  8. <div class="col-lg-8" style="padding-top: 15px; margin-top: 20px;">
  9. <div class="row">
  10. <div class="col-lg-3"></div>
  11. <div class="col-lg-3">
  12. <!-- <router-link v-if="userData.RoleDetails.IsCreateInventory" :to="{name: 'InventoryManagement.import'}" type="button" class="btn btn-info waves-effect waves-circle waves-float pull-right button-import">
  13. <img src="@/assets/images/file-import-solid.svg" style="width: 10%; height: 100%;" alt="Alternate Text" /> Import
  14. </router-link> -->
  15. </div>
  16. <div class="col-lg-3">
  17. <download-excel v-if="userData.RoleDetails.IsExportInventory" class="btn waves-effect waves-circle waves-float pull-right button-export"
  18. worksheet = "Daftar Inventory"
  19. name = "data_inventory.xls"
  20. :data = "exportData"
  21. :fields = "fieldsData">
  22. <img src="@/assets/images/file-text.png" alt="Alternate Text" /> Export
  23. </download-excel>
  24. </div>
  25. <div class="col-lg-3">
  26. <router-link v-if="userData.RoleDetails.IsCreateInventory" :to="{name: 'InventoryManagement.create'}" type="button" class="btn waves-effect waves-circle waves-float pull-right button-create">
  27. <img src="@/assets/images/plus-circle.png" alt="Alternate Text" /> Tambah
  28. </router-link>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33.  
  34. <div class="row">
  35. <div class="col-lg-4"></div>
  36. <div class="col-lg-8">
  37. <div class="row">
  38. <div class="col-lg-6"></div>
  39. <div class="col-lg-3">
  40. <!-- <select class="select-dropdown" name="" id="">
  41. <option value="" disabled selected>Pilih bendera...</option>
  42. <option value="Semua cabang">Semua bendera</option>
  43. <option value="Cabang A">Bendera A</option>
  44. <option value="Cabang B">Bendera B</option>
  45. </select> -->
  46. <vue-select v-if="userData.RoleId != 1" :disabled="$route.name.includes('.detail')" v-model="selectedLegalEntity" class="vue-select2" name="role" :options="userData.AccessSettings.filter(x => x.IsSelected == true)" label="Name"></vue-select>
  47. <vue-select v-if="userData.RoleId == 1" :disabled="$route.name.includes('.detail')" v-model="selectedLegalEntity" class="vue-select2" name="role" :options="legalEntity" label="Name"></vue-select>
  48. </div>
  49. <div class="col-lg-3">
  50. <!-- <select class="select-dropdown" name="" id="">
  51. <option value="" disabled selected>Pilih cabang...</option>
  52. <option value="Semua cabang">Semua cabang</option>
  53. <option value="Cabang A">Cabang A</option>
  54. <option value="Cabang B">Cabang B</option>
  55. </select> -->
  56. <vue-select v-if="userData.RoleId != 1 && selectedLegalEntity && selectedLegalEntity.branches !== undefined" :disabled="$route.name.includes('.detail')" v-model="selectedBranch" class="vue-select2" name="role" :options="selectedLegalEntity.branches.filter(x => x.IsSelected == 1)" label="Name"></vue-select>
  57. <vue-select v-if="userData.RoleId == 1 && selectedLegalEntity && selectedLegalEntity.branches !== undefined" :disabled="$route.name.includes('.detail')" v-model="selectedBranch" class="vue-select2" name="role" :options="selectedLegalEntity.branches" label="Name"></vue-select>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62.  
  63. <div class="row">
  64. <div class="col-lg-12 second-row">
  65.  
  66. <hr/>
  67. <div class="row">
  68. <div class="col-lg-6">
  69. <div class="row">
  70. <div class="col-lg-10 search-div">
  71. <input type="text" name="permission" placeholder="Cari inventory..." v-model="key" v-on:keyup.enter="search(key)" value="" style="width: 100%; height: 38px; float: right; margin-bottom: 10px; border: 1px solid rgba(184, 55, 62, 0.5); background-color: white; border-radius: 5px; padding: 5px; margin-bottom: 24px;" />
  72. </div>
  73. <div class="col-lg-1 search-div">
  74. <button class="btn btn-primary" @click="search(key)" ><span class="fa fa-search"></span></button>
  75. </div>
  76. <div class="col-lg-1 search-div">
  77. <button v-if="key != ''" class="btn btn-erase" @click="deleteSearch()"><span class="fa fa-times"></span></button>
  78. </div>
  79. </div>
  80. </div>
  81.  
  82. </div>
  83. </div>
  84. </div>
  85.  
  86. <div class="row">
  87. <div class="col-lg-12">
  88. <div class="table-div" style="height: 530px !important;">
  89. <b-table striped sticky-header hover
  90. id="inventoryTable"
  91. :items="filtered"
  92. :fields="fieldLookup()"
  93. :filter="query"
  94. class="table table-hover table-striped"
  95. style="margin-top: 10px; max-height: 500px !important">
  96. <template v-slot:cell(Actions)="data">
  97. <b-dropdown text="Action" variant="primary" style="width: 120px;" v-if="!data.item.inventory.Category.includes('Bundle')">
  98. <b-dropdown-item v-if="userData.RoleDetails.IsUpdateInventory" @click="edit(data.item.inventory.Id)">Edit</b-dropdown-item>
  99. <b-dropdown-item v-if="userData.RoleDetails.IsDeleteInventory" @click="del(data.item.inventory, data.item.inventory.Id)">Delete</b-dropdown-item>
  100. </b-dropdown>
  101. </template>
  102. <template v-slot:cell(Code)="data">
  103. <a v-if="userData.RoleDetails.IsReadInventory" @click="detail(data.item.inventory.Id)" style="color: #0059aa; cursor: pointer; font-weight: 700;">{{ data.item.inventory.Code }}</a>
  104. <label v-else>{{ data.item.inventory.Code }}</label>
  105. </template>
  106. <template v-slot:cell(Name)="data">
  107. {{ data.item.inventory.Name }}
  108. </template>
  109. <template v-slot:cell(Category)="data">
  110. {{ data.item.inventory.Category }}
  111. </template>
  112. <template v-slot:cell(WarehouseCategory)="data">
  113. {{ data.item.inventory.WarehouseCategory }}
  114. </template>
  115. <template v-slot:cell(Price100)="data">
  116. {{ data.item.inventory.Price100 | currency }}
  117. </template>
  118. <template v-slot:cell(Price90)="data">
  119. {{ data.item.inventory.Price90 | currency }}
  120. </template>
  121. <template v-slot:cell(Price60)="data">
  122. {{ data.item.inventory.Price60 | currency }}
  123. </template>
  124. <template v-slot:cell(Price30)="data">
  125. {{ data.item.inventory.Price30 | currency }}
  126. </template>
  127. <template v-if="userData.RoleDetails.IsReadBuyingPriceInventory" v-slot:cell(BuyingPrice100)="data">
  128. {{ data.item.inventory.BuyingPrice100 | currency }}
  129. </template>
  130. <template v-if="userData.RoleDetails.IsReadBuyingPriceInventory" v-slot:cell(BuyingPrice90)="data">
  131. {{ data.item.inventory.BuyingPrice90 | currency }}
  132. </template>
  133. <template v-if="userData.RoleDetails.IsReadBuyingPriceInventory" v-slot:cell(BuyingPrice60)="data">
  134. {{ data.item.inventory.BuyingPrice60 | currency }}
  135. </template>
  136. <template v-if="userData.RoleDetails.IsReadBuyingPriceInventory" v-slot:cell(BuyingPrice30)="data">
  137. {{ data.item.inventory.BuyingPrice30 | currency }}
  138. </template>
  139. <template v-slot:cell(Point)="data">
  140. {{ data.item.inventory.Point | currency({ symbol: '', thousandsSeparator: '.', fractionCount: '2', fractionSeparator: ',', symbolPosition: '', symbolSpacing: '' }) }}
  141. </template>
  142. <template v-slot:cell(LegalEntityId)="data">
  143. {{ data.item.legal_entity.Name }}
  144. </template>
  145. <template v-slot:cell(BranchId)="data">
  146. {{ data.item.branch.Name }}
  147. </template>
  148. <template v-slot:cell(Location)="data">
  149. {{ data.item.Location }}
  150. </template>
  151. <template v-slot:cell(RefurbishQuantity)="data">
  152. {{ data.item.RefurbishQuantity | currency({ symbol: '', thousandsSeparator: '.', fractionCount: '', fractionSeparator: '', symbolPosition: '', symbolSpacing: '' }) }}
  153. </template>
  154. <template v-slot:cell(Quantity100)="data">
  155. {{ data.item.Quantity100 | currency({ symbol: '', thousandsSeparator: '.', fractionCount: '', fractionSeparator: '', symbolPosition: '', symbolSpacing: '' }) }}
  156. </template>
  157. <template v-slot:cell(Quantity90)="data">
  158. {{ data.item.Quantity90 | currency({ symbol: '', thousandsSeparator: '.', fractionCount: '', fractionSeparator: '', symbolPosition: '', symbolSpacing: '' }) }}
  159. </template>
  160. <template v-slot:cell(Quantity60)="data">
  161. {{ data.item.Quantity60 | currency({ symbol: '', thousandsSeparator: '.', fractionCount: '', fractionSeparator: '', symbolPosition: '', symbolSpacing: '' }) }}
  162. </template>
  163. <template v-slot:cell(Quantity30)="data">
  164. {{ data.item.Quantity30 | currency({ symbol: '', thousandsSeparator: '.', fractionCount: '', fractionSeparator: '', symbolPosition: '', symbolSpacing: '' }) }}
  165. </template>
  166. <template v-slot:cell(TotalQuantityC)="data">
  167. {{ calculateTotal(data.item) | currency({ symbol: '', thousandsSeparator: '.', fractionCount: '', fractionSeparator: '', symbolPosition: '', symbolSpacing: '' }) }}
  168. </template>
  169. <template v-slot:cell(SafetyStockStatus)="data">
  170. <div v-if="calculateTotal(data.item) > data.item.SafetyStockLimit">
  171. <button type="button" class="btn btn-success">Stock Aman</button>
  172. </div>
  173. <div v-else-if="(calculateTotal(data.item) <= data.item.SafetyStockLimit) && (calculateTotal(data.item) > 0)">
  174. <button type="button" class="btn btn-warning">Restock</button>
  175. </div>
  176. <div v-else-if="calculateTotal(data.item) <= 0">
  177. <button type="button" class="btn btn-danger">Stock Habis</button>
  178. </div>
  179. </template>
  180. </b-table>
  181. <div v-if="loading" class="d-flex justify-content-center mb-3">
  182. <b-spinner label="Loading..."></b-spinner>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. </template>
  189.  
  190. <script>
  191. import moment from 'moment'
  192. import $ from 'jquery'
  193. import DownloadExcel from 'vue-json-excel'
  194. import VueSelect from 'vue-select'
  195. import 'vue-select/dist/vue-select.css'
  196.  
  197. import Inventories from '@/services/Inventories/Inventory'
  198. import LegalEntities from '@/services/Companies/LegalEntities'
  199. import Branches from '@/services/Companies/Branches'
  200.  
  201. export default {
  202. name: 'InventoryManagement.index',
  203. components: {
  204. DownloadExcel,
  205. VueSelect
  206. },
  207. computed: {
  208. rows () {
  209. //hitung panjang data Inventory
  210. return this.inventory.length
  211. },
  212. filtered: function () {
  213.  
  214. let data = []
  215. let temp = this.filterAccessSetting(this.inventory)
  216.  
  217. /**
  218. * saat posisi ob observer dan terpilih
  219. */
  220. if(this.selectedLegalEntity != null) {
  221. if(this.selectedLegalEntity.Name == 'Pilih bendera...') {
  222. data = temp
  223. } else if(this.selectedLegalEntity.Name != 'Pilih bendera...') {
  224. // jika citra group dipilih maka semua bendera dan cabang visible
  225. if(this.selectedLegalEntity.Id == 1) {
  226. data = temp
  227. } else if(this.selectedLegalEntity.Id == 1 && this.selectedBranch.Id == 1) {
  228. data = temp
  229. // sisanya melalui filter
  230. } else {
  231. data = temp.filter(i => i.LegalEntityId == this.selectedLegalEntity.Id)
  232. if(this.selectedBranch != null) {
  233. if(this.selectedBranch.Name == 'Pilih cabang...') {
  234. data = temp.filter(i => i.LegalEntityId == this.selectedLegalEntity.Id)
  235. } else if(this.selectedBranch.Name != 'Pilih cabang...') {
  236. data = temp.filter(i => i.LegalEntityId == this.selectedLegalEntity.Id && i.BranchId == this.selectedBranch.Id)
  237. }
  238. } else if(this.selectedBranch == null) {
  239. data = temp.filter(i => i.LegalEntityId == this.selectedLegalEntity.Id)
  240. }
  241. }
  242. }
  243. } else if(this.selectedLegalEntity == null) {
  244. data = temp
  245. }
  246.  
  247. return data
  248. }
  249. },
  250. data () {
  251. return {
  252. key: '',
  253. query: '',
  254. //Loading
  255. loading: true,
  256. //definisikan per page dan halaman current isi 1 untuk awal
  257. perPage: 10,
  258. currentPage: 1,
  259. //selesai
  260. // inventoryField: this.fieldLookup(),
  261. exportData: [],
  262. fieldsData: {
  263. 'Kode': 'Code',
  264. 'Nama Bendera': 'LegalEntityId',
  265. 'Nama Cabang': 'BranchId',
  266. 'Name Barang': 'Name',
  267. 'Lokasi': 'Location',
  268. 'Kategori': 'Category',
  269. 'Jumlah Barang': 'TotalQuantity',
  270. 'Jumlah Barang Rekondisi': 'RefurbishQuantity',
  271. 'Jumlah Barang Kondisi 100%': 'Quantity100',
  272. 'Jumlah Barang Kondisi 90%': 'Quantity90',
  273. 'Jumlah Barang Kondisi 60%': 'Quantity60',
  274. 'Jumlah Barang Kondisi 30%': 'Quantity30',
  275. 'Safety Stock Limit': 'SafetyStockStatus',
  276. 'Harga Jual 100%': 'Price90',
  277. 'Harga Jual 90%': 'Price90',
  278. 'Harga Jual 60%': 'Price60',
  279. 'Harga Jual 30%': 'Price30',
  280. 'Harga Jual Owner 100%': 'ExtraPrice90',
  281. 'Harga Jual Owner 90%': 'ExtraPrice90',
  282. 'Harga Jual Owner 60%': 'ExtraPrice60',
  283. 'Harga Jual Owner 30%': 'ExtraPrice30',
  284. 'Harga Beli 100%': 'BuyingPrice90',
  285. 'Harga Beli 90%': 'BuyingPrice90',
  286. 'Harga Beli 60%': 'BuyingPrice60',
  287. 'Harga Beli 30%': 'BuyingPrice30',
  288. 'Point': 'Point',
  289. },
  290. userData: {},
  291. inventory: [],
  292. roles: [],
  293. selectedLegalEntity: {"Name" : "Pilih bendera..."},
  294. selectedBranch: {"Name" : "Pilih cabang..."},
  295. legalEntity: [],
  296. branch: [],
  297. dismissSecs: 5,
  298. dismissCountDown: 0,
  299. deleted: [],
  300. selectorLegalEntity: 0,
  301. selectorBranch: 0,
  302. buyingPriceAccess: 0,
  303. sellingPriceAccess: 0,
  304. editor: null
  305. }
  306. },
  307. created: function () {
  308. this.init()
  309. },
  310. mounted: function () {
  311. window.$ = $
  312. if(localStorage.userData !== undefined) {
  313. this.userData = JSON.parse(localStorage.userData)
  314. } else {
  315. this.$router.push({ name: 'home' })
  316. location.reload()
  317. }
  318. },
  319. beforeUpdate: function() {
  320. // if(this.selectedLegalEntity.Name != 'Pilih bendera...') {
  321. // //this.query = this.selectedLegalEntity.Name
  322. // this.selectorLegalEntity = this.selectedLegalEntity.Id
  323. // } else {
  324. // this.selectorLegalEntity = this.userData.LegalEntityId
  325. // }
  326.  
  327. // if(this.selectedBranch.Name != 'Pilih cabang...') {
  328. // //this.query = this.selectedBranch.Name
  329. // this.selectorBranch = this.selectedBranch.Id
  330. // } else {
  331. // this.selectorBranch = this.userData.BranchId
  332.  
  333. // }
  334. this.buyingPriceAccess = this.userData.RoleDetails.IsReadBuyingPriceInventory
  335. this.sellingPriceAccess = this.userData.RoleDetails.IsReadSellingPriceInventory
  336.  
  337. this.editor = this.userData.EmployeeId
  338.  
  339. console.log(this.filterAccessSetting(this.inventory))
  340. console.log(this.selectedLegalEntity.Name)
  341. console.log(this.selectedBranch.Name)
  342. },
  343. methods: {
  344. init: async function () {
  345. let result = await Inventories.getBranches()
  346. let legalEntity = await LegalEntities.index()
  347. let branch = await Branches.index()
  348.  
  349. this.inventory = result.data
  350. this.legalEntity = legalEntity.data
  351. this.branch = branch.data
  352. this.loading = false
  353. //fungsi export
  354. this.exportData = this.filterExport(result.data)
  355.  
  356. console.log(this.userData.AccessSettings)
  357. },
  358. fieldLookup() {
  359. let field = [
  360. { key: 'Actions', label: 'Actions' },
  361. { key: 'Code', label: 'Nomor Barang', sortable: true },
  362. { key: 'LegalEntityId', label: 'Nama Bendera', sortable: true },
  363. { key: 'BranchId', label: 'Nama Cabang', sortable: true },
  364. { key: 'Name', label: 'Nama Barang', sortable: true },
  365. { key: 'Category', label: 'Kategori Barang', sortable: true },
  366. { key: 'WarehouseCategory', label: 'Kategori Gudang', sortable: true },
  367. { key: 'Location', label: 'Lokasi', sortable: true },
  368. { key: 'Point', label: 'Points', sortable: true },
  369. { key: 'SafetyStockStatus', label: 'Status Stock', sortable: true },
  370. { key: 'TotalQuantityC', label: 'Jumlah Barang', sortable: true },
  371. { key: 'Quantity100', label: 'Kondisi 100%', sortable: true },
  372. { key: 'Quantity90', label: 'Kondisi 90%', sortable: true },
  373. { key: 'Quantity60', label: 'Kondisi 60%', sortable: true },
  374. { key: 'Quantity30', label: 'Kondisi dibawah 30%', sortable: true },
  375. { key: 'RefurbishQuantity', label: 'Jumlah Barang Rekondisi', sortable: true },
  376. ]
  377. // if(this.userData.RoleDetails.IsReadSellingPriceInventory == 1 && this.userData.RoleDetails.IsReadBuyingPriceInventory == 0) {
  378. // field.splice(16, 0,
  379. // { key: 'Price100', label: 'Harga Jual Kondisi 100%', sortable: true },
  380. // { key: 'Price90', label: 'Harga Jual Kondisi 90%', sortable: true },
  381. // { key: 'Price60', label: 'Harga Jual Kondisi 60%', sortable: true },
  382. // { key: 'Price30', label: 'Harga Jual Kondisi 30%', sortable: true },
  383. // )
  384. // }
  385. // if(this.userData.RoleDetails.IsReadBuyingPriceInventory == 1 && this.userData.RoleDetails.IsReadSellingPriceInventory == 0) {
  386. // field.splice(16, 0,
  387. // { key: 'BuyingPrice100', label: 'Harga Beli Kondisi 100%', sortable: true },
  388. // { key: 'BuyingPrice90', label: 'Harga Beli Kondisi 90%', sortable: true },
  389. // { key: 'BuyingPrice60', label: 'Harga Beli Kondisi 60%', sortable: true },
  390. // { key: 'BuyingPrice30', label: 'Harga Beli Kondisi 30%', sortable: true }
  391. // )
  392. // }
  393. // if(this.userData.RoleDetails.IsReadBuyingPriceInventory == 1 && this.userData.RoleDetails.IsReadSellingPriceInventory == 1) {
  394. // field.splice(16, 0,
  395. // { key: 'Price100', label: 'Harga Jual Kondisi 100%', sortable: true },
  396. // { key: 'Price90', label: 'Harga Jual Kondisi 90%', sortable: true },
  397. // { key: 'Price60', label: 'Harga Jual Kondisi 60%', sortable: true },
  398. // { key: 'Price30', label: 'Harga Jual Kondisi 30%', sortable: true },
  399. // { key: 'BuyingPrice100', label: 'Harga Beli Kondisi 100%', sortable: true },
  400. // { key: 'BuyingPrice90', label: 'Harga Beli Kondisi 90%', sortable: true },
  401. // { key: 'BuyingPrice60', label: 'Harga Beli Kondisi 60%', sortable: true },
  402. // { key: 'BuyingPrice30', label: 'Harga Beli Kondisi 30%', sortable: true }
  403. // )
  404. // }
  405. return field
  406. },
  407. calculateTotal: function(json) {
  408. let total = parseInt(json.Quantity100) + parseInt(json.Quantity90) + parseInt(json.Quantity60) + parseInt(json.Quantity30)
  409. return total
  410. },
  411. search: function(key) {
  412. this.query = key
  413. },
  414. deleteSearch: function() {
  415. this.query = ''
  416. this.key = ''
  417. },
  418. // cekSafetyStock: function(safetyStock, legalEntityId, branchId) {
  419.  
  420. // },
  421.  
  422. filterAccessSetting: function(json) {
  423. /**
  424. * JSON adalah daftar inventory
  425. */
  426. let access = this.userData.AccessSettings
  427. let data = []
  428. for(var i = 0; i < access.length; i++) {
  429. for(var j = 0; j < json.length; j++) {
  430. if(access[i].IsSelected == true) {
  431. if(access[i].Id == json[j].LegalEntityId) {
  432. let branch = access[i].branches
  433. if(branch.length > 0) {
  434. for(var k = 0; k < branch.length; k++) {
  435. if(branch[k].IsSelected == true) {
  436. if(branch[k].Id == json[j].BranchId) {
  437. data.push(json[j])
  438. }
  439. }
  440. }
  441. }
  442. }
  443. }
  444. }
  445. }
  446. return data
  447. },
  448.  
  449. filterBarangCabang: function(json, legalEntityId, branchId) {
  450. let data = []
  451. for(var i = 0; i < json.length; i++) {
  452. if((json[i].LegalEntityId == legalEntityId) && (json[i].BranchId == branchId)) {
  453. data.push(json[i])
  454. }
  455. }
  456. return data
  457. },
  458.  
  459. filterPosisiBenderaCabangSaatIni: function(json, legalEntityId, branchId) {
  460. for(var i = 0; i < json.length; i++) {
  461. if((json[i].LegalEntityId == legalEntityId) && (json[i].BranchId == branchId)) {
  462. return true
  463. } else {
  464. return false
  465. }
  466. }
  467. },
  468.  
  469. //Filter data yang mau di export
  470. filterExport: function (json) {
  471. let data = []
  472. for(var i = 0; i< json.length; i++) {
  473. //Tentukan Kolom Yang Mau Dimasukin Disini
  474. data.push({
  475. 'Code': json[i].Code,
  476. 'LegalEntityId': json[i].legal_entity ? json[i].legal_entity.Name : '-',
  477. 'BranchId': json[i].branch ? json[i].branch.Name : '-',
  478. 'Name': json[i].Name,
  479. 'Location': json[i].Location,
  480. 'Category': json[i].Category,
  481. 'TotalQuantity': this.calculateTotal(json[i].inventory_branches[0]),
  482. 'RefurbishQuantity': json[i].inventory_branches[0].RefurbishQuantity,
  483. 'Quantity100': json[i].inventory_branches[0].Quantity100,
  484. 'Quantity90': json[i].inventory_branches[0].Quantity90,
  485. 'Quantity60': json[i].inventory_branches[0].Quantity60,
  486. 'Quantity30': json[i].inventory_branches[0].Quantity30,
  487. 'SafetyStockStatus': json[i].inventory_branches[0].SafetyStockLimit,
  488. 'Price100': json[i].Price100,
  489. 'Price90': json[i].Price90,
  490. 'Price60': json[i].Price60,
  491. 'Price30': json[i].Price30,
  492. 'BuyingPrice100': json[i].BuyingPrice100,
  493. 'BuyingPrice90': json[i].BuyingPrice90,
  494. 'BuyingPrice60': json[i].BuyingPrice60,
  495. 'BuyingPrice30': json[i].BuyingPrice30,
  496. 'ExtraPrice100': json[i].ExtraPrice100,
  497. 'ExtraPrice90': json[i].ExtraPrice90,
  498. 'ExtraPrice60': json[i].ExtraPrice60,
  499. 'ExtraPrice30': json[i].ExtraPrice30,
  500. 'Point': json[i].Point,
  501. })
  502. }
  503. return data
  504. },
  505. itemLookup: function (json) {
  506. let data = []
  507. for(var i = 0; i< json.length; i++) {
  508. data[json[i].Id] = json[i]
  509. }
  510. return data
  511. },
  512. formatDate(time) {
  513. var formattedTime = moment(time).format('DD MMMM YYYY HH:mm')
  514. if(formattedTime == 'Invalid date') {
  515. formattedTime = '-'
  516. }
  517. return formattedTime
  518. },
  519. detail: function (id) {
  520. this.$router.push({ name: 'InventoryManagement.detail', params: { id: id } })
  521. },
  522. edit: function (id) {
  523. this.$router.push({ name: 'InventoryManagement.edit', params: { id: id } })
  524. },
  525. del: async function (json, id) {
  526. console.log(id)
  527.  
  528. json.EditorId = this.editor
  529. json.PermanentDelete = true
  530. json.LoggedUserLegalEntityId = this.userData.LegalEntityId
  531. json.LoggedUserBranchId = this.userData.BranchId
  532. json.TotalQuantity = json.inventory_branches[0].TotalQuantity
  533.  
  534. console.log(json)
  535.  
  536. let ini = this
  537. ini.$fire({
  538. text: "Apakah anda yakin ingin menghapus " + json.Name + "?",
  539. type: "warning",
  540. showCancelButton: true,
  541. confirmButtonText: 'Ya',
  542. cancelButtonText: 'Tidak',
  543. showCloseButton: true,
  544. showLoaderOnConfirm: true,
  545. }).then(function(isConfirm) {
  546. if (isConfirm.value) {
  547. ini.$fire({
  548. text: "Peringatan terakhir! Apakah anda yakin ingin menghapus " + json.Name + "?",
  549. type: "warning",
  550. showCancelButton: true,
  551. confirmButtonText: 'Ya',
  552. cancelButtonText: 'Tidak',
  553. showCloseButton: true,
  554. showLoaderOnConfirm: true,
  555. }).then(async function(isConfirm) {
  556. if (isConfirm.value) {
  557. let result = await Inventories.delete(id, json)
  558.  
  559. if(result.status == 200) {
  560. ini.$fire({
  561. title: 'Sukses',
  562. text: 'Hapus Data Sukses',
  563. showConfirmButton: false
  564. })
  565. ini.$router.push({ name: 'InventoryManagement.index' })
  566. location.reload()
  567. } else {
  568. alert("Delete Gagal")
  569. location.reload()
  570. }
  571. console.log('Keluar')
  572. }
  573. })
  574. } else {
  575. console.log('cancel')
  576. }
  577. })
  578. },
  579. countDownChanged(dismissCountDown) {
  580. this.dismissCountDown = dismissCountDown
  581. },
  582. }
  583. }
  584. </script>
  585.  
  586. <style>
  587. .table-div {
  588. height: 500px;
  589. padding-left: 30px;
  590. margin-left: 0px !important;
  591. overflow-x: auto;
  592. overflow-y: auto;
  593. }
  594.  
  595. .second-row {
  596. margin-top: 30px;
  597. padding-left: 30px;
  598. }
  599.  
  600. .select-dropdown {
  601. width: 100%;
  602. height: 45px;
  603. border-color: #0059aa;
  604. border-radius: 5px;
  605. }
  606.  
  607. .button-export {
  608. width: 100%;
  609. height: 45px;
  610. background-color: #0059aa;
  611. color:white;
  612. border-radius: 5px;
  613. }
  614.  
  615. .button-create {
  616. width: 100%;
  617. height: 45px;
  618. background-color: #20c197;
  619. color:white;
  620. border-radius: 5px;
  621. }
  622.  
  623. .btn-warning {
  624. width: 132px;
  625. }
  626.  
  627. .btn-danger {
  628. margin-left: 0px !important;
  629. }
  630.  
  631. .btn-default {
  632. width: 132px;
  633. height: 36px;
  634. margin-left: 15px;
  635. margin-right: 15px;
  636. color: white;
  637. background-color: red;
  638. }
  639.  
  640. .btn-default:hover {
  641. color: white;
  642. background-color: rgb(185, 0, 0);
  643. }
  644.  
  645. .pagination {
  646. padding: 15px;
  647. }
  648. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement