소스 검색

Improves store name display code.

Christopher Leggett 5 년 전
부모
커밋
5443878823
2개의 변경된 파일68개의 추가작업 그리고 71개의 파일을 삭제
  1. 59 59
      public/js/app.js
  2. 9 12
      resources/js/components/woinfo.vue

+ 59 - 59
public/js/app.js

@@ -2192,7 +2192,6 @@ __webpack_require__.r(__webpack_exports__);
   data: function data() {
     return {
       data: JSON.parse(this.workOrder),
-      storeName: null,
       storeList: null
     };
   },
@@ -2201,28 +2200,20 @@ __webpack_require__.r(__webpack_exports__);
 
     Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
       _this.data = JSON.parse(e.data);
-      _this.storeName = _this.getStoreName();
     });
     axios.get('/api/stores').then(function (response) {
-      _this.storeList = response.data;
+      _this.storeList = new Map();
+      response.data.map(function (val) {
+        _this.storeList.set(val.storeid, val);
+      });
     })["catch"](function (error) {
       console.error(error);
     });
-    this.storeList = this.getStoreName();
   },
   methods: {
     updateWorkOrder: function updateWorkOrder() {
       axios.put('/api/workorders/' + this.data.woid, this.data).then(function (response) {})["catch"](function (error) {});
       $('#workordereditModal').modal('hide');
-    },
-    getStoreName: function getStoreName() {
-      var _this2 = this;
-
-      axios.get('/api/stores/' + this.data.storeid).then(function (response) {
-        _this2.storeName = response.data.storesname;
-      })["catch"](function (error) {
-        console.error(error);
-      });
     }
   }
 });
@@ -49208,54 +49199,59 @@ var render = function() {
             _c("div", { staticClass: "form-group" }, [
               _c("label", { attrs: { for: "storelist" } }, [_vm._v("Store")]),
               _vm._v(" "),
-              _c(
-                "select",
-                {
-                  directives: [
+              _vm.storeList
+                ? _c(
+                    "select",
                     {
-                      name: "model",
-                      rawName: "v-model",
-                      value: _vm.data.storeid,
-                      expression: "data.storeid"
-                    }
-                  ],
-                  staticClass: "form-control",
-                  attrs: { name: "storelist", id: "storelist" },
-                  on: {
-                    change: function($event) {
-                      var $$selectedVal = Array.prototype.filter
-                        .call($event.target.options, function(o) {
-                          return o.selected
-                        })
-                        .map(function(o) {
-                          var val = "_value" in o ? o._value : o.value
-                          return val
-                        })
-                      _vm.$set(
-                        _vm.data,
-                        "storeid",
-                        $event.target.multiple
-                          ? $$selectedVal
-                          : $$selectedVal[0]
-                      )
-                    }
-                  }
-                },
-                _vm._l(_vm.storeList, function(store) {
-                  return _c(
-                    "option",
-                    { key: store.storeid, domProps: { value: store.storeid } },
-                    [
-                      _vm._v(
-                        "\n                        " +
-                          _vm._s(store.storesname) +
-                          "\n                    "
+                      directives: [
+                        {
+                          name: "model",
+                          rawName: "v-model",
+                          value: _vm.data.storeid,
+                          expression: "data.storeid"
+                        }
+                      ],
+                      staticClass: "form-control",
+                      attrs: { name: "storelist", id: "storelist" },
+                      on: {
+                        change: function($event) {
+                          var $$selectedVal = Array.prototype.filter
+                            .call($event.target.options, function(o) {
+                              return o.selected
+                            })
+                            .map(function(o) {
+                              var val = "_value" in o ? o._value : o.value
+                              return val
+                            })
+                          _vm.$set(
+                            _vm.data,
+                            "storeid",
+                            $event.target.multiple
+                              ? $$selectedVal
+                              : $$selectedVal[0]
+                          )
+                        }
+                      }
+                    },
+                    _vm._l(_vm.storeList.values(), function(store) {
+                      return _c(
+                        "option",
+                        {
+                          key: store.storeid,
+                          domProps: { value: store.storeid }
+                        },
+                        [
+                          _vm._v(
+                            "\n                        " +
+                              _vm._s(store.storesname) +
+                              "\n                    "
+                          )
+                        ]
                       )
-                    ]
+                    }),
+                    0
                   )
-                }),
-                0
-              )
+                : _vm._e()
             ])
           ]),
           _vm._v(" "),
@@ -49307,7 +49303,11 @@ var render = function() {
       _c("p", [
         _c("i", { staticClass: "fas fa-fw fa-building" }),
         _vm._v(" "),
-        _c("span", [_vm._v(_vm._s(_vm.storeName))])
+        this.storeList
+          ? _c("span", [
+              _vm._v(_vm._s(this.storeList.get(this.data.storeid).storesname))
+            ])
+          : _vm._e()
       ]),
       _vm._v(" "),
       _c("p", [

+ 9 - 12
resources/js/components/woinfo.vue

@@ -15,8 +15,8 @@
                 </div>
                 <div class="form-group">
                     <label for="storelist">Store</label>
-                    <select name="storelist" id="storelist" class="form-control" v-model="data.storeid">
-                        <option v-for="store in storeList" v-bind:key="store.storeid" v-bind:value="store.storeid">
+                    <select name="storelist" id="storelist" class="form-control" v-if="storeList" v-model="data.storeid">
+                        <option v-for="store in storeList.values()" v-bind:key="store.storeid" v-bind:value="store.storeid">
                             {{ store.storesname }}
                         </option>
                     </select>
@@ -31,7 +31,7 @@
         <p><i class="fas fa-fw fa-info-circle"></i> <span v-text="this.data.probdesc"></span></p>
         <p><i class="far fa-fw fa-lightbulb"></i> <span v-text="this.data.suggested"></span></p>
         <p><i class="fas fa-fw fa-paste"></i> <span v-text="this.data.woid"></span></p>
-        <p><i class="fas fa-fw fa-building"></i> <span>{{ storeName }}</span></p>
+        <p><i class="fas fa-fw fa-building"></i> <span v-if="this.storeList">{{ this.storeList.get(this.data.storeid).storesname }}</span></p>
         <p><i class="fas fa-fw fa-sign-in-alt"></i> 
             <span class="dashed-underline" data-toggle="tooltip" data-placement="bottom" v-bind:title=this.getHRDate(this.data.dropdate)>
                 {{ Math.floor(this.daysSinceToday(this.data.dropdate)) }} days ago
@@ -53,7 +53,6 @@
         data() {
             return {
                 data: JSON.parse(this.workOrder),
-                storeName: null,
                 storeList: null,
             }
         },
@@ -61,10 +60,13 @@
             Echo.channel('work-orders')
                 .listen('WorkOrderUpdated', (e) => {
                     this.data = JSON.parse(e.data);
-                    this.storeName = this.getStoreName();
                 });
-            axios.get('/api/stores').then((response) => { this.storeList = response.data }).catch((error) => { console.error(error) });
-            this.storeList = this.getStoreName();
+            axios.get('/api/stores').then((response) => {
+                    this.storeList = new Map();
+                    response.data.map(val => { 
+                        this.storeList.set(val.storeid, val);
+                    });
+                }).catch((error) => { console.error(error) });
         },
         methods: {
             updateWorkOrder() {
@@ -73,11 +75,6 @@
                     .catch((error) => {});
                 $('#workordereditModal').modal('hide');
             },
-            getStoreName() {
-                axios.get('/api/stores/' + this.data.storeid)
-                    .then((response) => { this.storeName = response.data.storesname })
-                    .catch((error) => { console.error(error) });
-            }
         }
     }
 </script>