UserStoreBasketShow.vue 9.7 KB

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