UserStoreBasketShow.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div class="UserStoreBasketShow"
  3. :style="localOptions.style">
  4. <div class="flex justify-end">
  5. <q-btn flat
  6. color="grey"
  7. @click="$router.go(-1)">
  8. بازگشت
  9. >
  10. </q-btn>
  11. </div>
  12. <entity-show v-if="mounted"
  13. ref="entityShow"
  14. v-model:value="inputs"
  15. title="جزییات صورتحساب"
  16. :api="api"
  17. :entity-id-key="entityIdKey"
  18. :entity-param-key="entityParamKey"
  19. :show-close-button="false"
  20. :show-edit-button="false"
  21. :show-expand-button="false"
  22. :show-reload-button="false"
  23. :show-index-button="false"
  24. :after-load-input-data="afterLoadInputData">
  25. <template #before-form-builder>
  26. <div class="basket-form-header row">
  27. <div class="col-md-4 col-12 flex justify-start items-center">
  28. <q-icon name="shopping_cart" />
  29. شناسه:
  30. {{ basket.id }}
  31. </div>
  32. <div class="col-md-8 col-12">
  33. <span class="text-info">
  34. {{ basket.status_info.label }}
  35. </span>
  36. <q-linear-progress :value="basketStatusProgress"
  37. color="info"
  38. size="16px"
  39. rounded
  40. class="q-mt-سپ" />
  41. </div>
  42. </div>
  43. </template>
  44. </entity-show>
  45. <div class="q-mt-md">
  46. <entity-index v-if="basket.id"
  47. v-model:value="tableInputs"
  48. title="لیست محصولات سفارش"
  49. :table="table"
  50. :loaded-data="basket"
  51. :table-keys="tableKeys"
  52. :show-search-button="false"
  53. :show-expand-button="false"
  54. :show-reload-button="false">
  55. <template #entity-index-table-cell="{inputData}">
  56. <template v-if="inputData.col.name === 'number'">
  57. {{ inputData.rowNumber }}
  58. </template>
  59. <template v-else-if="inputData.col.name === 'thumbnail'">
  60. <q-img :src="inputData.col.value"
  61. width="100px" />
  62. </template>
  63. <template v-else-if="inputData.col.name === 'download'">
  64. <q-btn v-if="!inputData.col.value"
  65. color="primary"
  66. @click="openDownloadDialog(inputData.props.row)">
  67. <q-icon name="download"
  68. class="q-mr-sm" />
  69. دانلود
  70. </q-btn>
  71. <template v-else>
  72. {{}}
  73. </template>
  74. </template>
  75. <template v-else-if="inputData.col.name === 'action'">
  76. <q-btn color="primary"
  77. outline
  78. :to="{name: inputData.props.row.product ? 'Public.Product' : 'Public.Package', params: {id: inputData.props.row.product || inputData.props.row.package}}">
  79. <q-icon name="visibility"
  80. class="q-mr-sm" />
  81. مشاهده
  82. </q-btn>
  83. </template>
  84. <template v-else>
  85. {{ inputData.col.value }}
  86. </template>
  87. </template>
  88. </entity-index>
  89. <q-dialog v-model="downloadDialog">
  90. <q-card style="width: 800px; max-width: 95%;">
  91. <q-card-section>
  92. محتوای قابل دانلود
  93. </q-card-section>
  94. <q-separator />
  95. <q-card-section>
  96. <product-or-package-medias :basket-item="selectedBasketItem" />
  97. </q-card-section>
  98. </q-card>
  99. </q-dialog>
  100. </div>
  101. </div>
  102. </template>
  103. <script>
  104. import { shallowRef } from 'vue'
  105. // import { Package } from 'src/models/Package'
  106. import { Basket } from 'src/models/Basket.js'
  107. import { Product } from 'src/models/Product.js'
  108. import { mixinWidget } from 'src/mixin/Mixins.js'
  109. import { APIGateway } from 'src/api/APIGateway.js'
  110. import { EntityShow, EntityIndex } from 'quasar-crud'
  111. import { FormBuilderAssist } from 'quasar-form-builder'
  112. import ProductOrPackageMedias from './ProductOrPackageMedias.vue'
  113. import FormBuilderDateTime from 'src/components/FormBuilderCustumComponents/FormBuilderDateTime.vue'
  114. const FormBuilderDateTimeComp = shallowRef(FormBuilderDateTime)
  115. export default {
  116. name: 'AdminStoreBasketShow',
  117. components: {
  118. EntityShow,
  119. EntityIndex,
  120. ProductOrPackageMedias
  121. },
  122. mixins: [mixinWidget],
  123. data () {
  124. return {
  125. mounted: false,
  126. downloadDialog: false,
  127. selectedBasketItem: null,
  128. entityLoading: false,
  129. api: APIGateway.basket.APIAdresses.byId(this.$route.params.id),
  130. entityIdKey: 'id',
  131. entityParamKey: 'id',
  132. indexRouteName: 'UserPanel.MyOrders.List',
  133. inputs: [],
  134. tableKeys: {
  135. data: 'items_info.list',
  136. total: 'count',
  137. currentPage: 'current',
  138. perPage: 'per_page',
  139. pageKey: 'page'
  140. },
  141. tableInputs: [],
  142. table: {
  143. columns: [
  144. {
  145. name: 'number',
  146. required: true,
  147. label: 'شماره',
  148. align: 'left',
  149. field: () => ''
  150. },
  151. {
  152. name: 'id',
  153. required: true,
  154. label: 'شناسه',
  155. align: 'left',
  156. field: row => row.product_info?.id ? row.product_info.id : row.package_info.id
  157. },
  158. {
  159. name: 'title',
  160. required: true,
  161. label: 'نام محصول',
  162. align: 'left',
  163. field: row => (row.product_info?.id ? row.product_info : row.package_info).title
  164. },
  165. {
  166. name: 'is_package_or_product',
  167. required: true,
  168. label: 'نوع محصول',
  169. align: 'left',
  170. field: row => row.package ? 'بسته' : 'تکی'
  171. },
  172. {
  173. name: 'store_category',
  174. required: true,
  175. label: 'دسته فروشگاه',
  176. align: 'left',
  177. field: row => ((row.product_info?.id ? row.product_info : row.package_info).store_category_info?.parent?.parent?.title || '-') + '، ' + ((row.product_info || row.package_info).store_category_info?.parent?.title || '-') + '، ' + ((row.product_info || row.package_info).store_category_info?.title || '-')
  178. },
  179. {
  180. name: 'store_category1',
  181. required: true,
  182. label: 'دسته محتوا',
  183. align: 'left',
  184. field: row => ((row.product_info?.id ? row.product_info : row.package_info).content_category_info?.parent?.parent?.title || '-') + '، ' + ((row.product_info || row.package_info).content_category_info?.parent?.title || '-') + '، ' + ((row.product_info || row.package_info).content_category_info?.title || '-')
  185. },
  186. {
  187. name: 'count',
  188. required: true,
  189. label: 'تعداد',
  190. align: 'left',
  191. field: row => row.count
  192. },
  193. {
  194. name: 'is_physical_info',
  195. required: true,
  196. label: 'نوع جنس',
  197. align: 'left',
  198. field: row => (row.product_info?.id ? row.product_info : row.package_info).is_physical_info.label
  199. },
  200. {
  201. name: 'physical_type_info',
  202. required: true,
  203. label: 'نوع محصول',
  204. align: 'left',
  205. field: row => row.product_info ? (new Product(row.product_info)).physical_type_info.label : '-'
  206. },
  207. {
  208. name: 'unit_price',
  209. required: true,
  210. label: 'قیمت',
  211. align: 'left',
  212. field: row => parseInt((row.product_info?.id ? row.product_info : row.package_info).unit_price?.toString()).toLocaleString('fa')
  213. },
  214. {
  215. name: 'download',
  216. required: true,
  217. label: 'دانلود',
  218. align: 'left',
  219. field: row => (row.product_info?.id ? row.product_info : row.package_info).is_physical
  220. },
  221. {
  222. name: 'action',
  223. required: true,
  224. label: 'مشاهده',
  225. align: 'left',
  226. field: row => ''
  227. }
  228. ]
  229. },
  230. basket: new Basket()
  231. }
  232. },
  233. computed: {
  234. basketStatusProgress () {
  235. if (this.basket.status === 'OPEN') {
  236. return 0.1
  237. }
  238. if (this.basket.status === 'CANCELED') {
  239. return 0
  240. }
  241. if (this.basket.status === 'PAID') {
  242. return 0.5
  243. }
  244. if (this.basket.status === 'CLOSED') {
  245. return 1
  246. }
  247. if (this.basket.status === 'SENT') {
  248. return 1
  249. }
  250. return 0.5
  251. }
  252. },
  253. created() {
  254. this.inputs = [
  255. { type: 'separator', name: 'space1', label: 'مشخصات سفارش', className: 'custom-separator', col: 'col-12' },
  256. { type: 'input', name: 'id', responseKey: 'id', label: 'شناسه', placeholder: ' ', disable: true, col: 'col-md-2 col-12' },
  257. { type: 'input', name: 'items_info.length', responseKey: 'items_info.length', label: 'تعداد اقلام', placeholder: ' ', disable: true, col: 'col-md-1 col-12' },
  258. { type: FormBuilderDateTimeComp, name: 'creation_time', responseKey: 'creation_time', outsideLabel: 'تاریخ ثبت', placeholder: ' ', disable: true, col: 'col-md-6 col-12' },
  259. { type: 'input', name: 'overall_order_price', responseKey: 'overall_order_price', label: 'قیمت کل(ریال)', placeholder: ' ', disable: true, col: 'col-md-3 col-12' }
  260. ]
  261. },
  262. mounted() {
  263. this.mounted = true
  264. },
  265. methods: {
  266. openDownloadDialog (basketItem) {
  267. this.selectedBasketItem = basketItem
  268. this.downloadDialog = true
  269. },
  270. afterLoadInputData (data) {
  271. this.entityLoading = false
  272. this.basket = new Basket(data)
  273. FormBuilderAssist.setAttributeByName(this.inputs, 'overall_order_price', 'value', parseInt(data.overall_order_price).toLocaleString('fa'))
  274. }
  275. }
  276. }
  277. </script>
  278. <style scoped lang="scss">
  279. .UserStoreBasketShow {
  280. .title {
  281. font-style: normal;
  282. font-weight: 700;
  283. font-size: 24px;
  284. line-height: 140%;
  285. color: #424242;
  286. margin-bottom: 27px;
  287. display: flex;
  288. flex-flow: row;
  289. position: relative;
  290. .static-title {
  291. }
  292. .dynamic-title {
  293. }
  294. .back-action {
  295. position: absolute;
  296. right: 0;
  297. top: 0;
  298. }
  299. }
  300. .basket-form-header {
  301. background: #FCF9F4;
  302. border: 1px solid #DFE1EC;
  303. margin: -16px -16px 0 -16px;
  304. padding: 16px 40px;
  305. .q-icon {
  306. color: #AAA095;
  307. }
  308. }
  309. :deep(.form) {
  310. padding: 24px;
  311. }
  312. :deep(.entity-index) {
  313. .entity-crud-formBuilder {
  314. display: none;
  315. }
  316. .q-table__bottom {
  317. display: none;
  318. }
  319. }
  320. }
  321. </style>