index.vue 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797
  1. <template>
  2. <div class="app-container">
  3. <div class="search" ref="search">
  4. <el-input v-model="table.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  5. <el-select v-model="table.getdataListParm.parammaps.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 150px;" clearable>
  6. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  7. </el-select>
  8. <el-select v-model="table.getdataListParm.parammaps.source" filterable placeholder="饲料来源" class="filter-item" style="width: 120px;" clearable>
  9. <el-option v-for="item in feedSourcesList" :key="item.id" :label="item.name" :value="item.id" />
  10. </el-select>
  11. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  12. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  13. </el-select>
  14. <div ref="selectInput" class="filter-item selectInput">
  15. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  16. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  17. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  18. <ul v-if="arrowUp" class="selectUl">
  19. <li><a>允许误差数</a><el-input v-model="table.getdataListParm.parammaps.allowratio"type="text" style="width: 245px;" /></li>
  20. <li><a>跳转重量域</a><el-input v-model="table.getdataListParm.parammaps.autozone" type="text" style="width: 245px;" /></li>
  21. <li>
  22. <a>跳转延时</a>
  23. <el-select v-model="table.getdataListParm.parammaps.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 245px;" clearable>
  24. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  25. </el-select>
  26. </li>
  27. <li>
  28. <div style="float: right;">
  29. <el-button class="downminCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  30. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  31. </div>
  32. </li>
  33. </ul>
  34. </div>
  35. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  36. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  37. </div>
  38. <div class="operation" ref="operation">
  39. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新增</el-button>
  40. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
  41. <el-button class="success" icon="el-icon-receiving" @click="handleFeedBank">饲料库</el-button>
  42. <el-button v-if="isOrder && isRoleEdit" icon="el-icon-sort" class="success" @click="handleChangeOrder">更改顺序</el-button>
  43. <div v-else style="display: inline-block;">
  44. <el-button v-if="isRoleEdit" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
  45. <el-button v-if="isRoleEdit" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
  46. </div>
  47. <el-upload style="float: right;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  48. <el-button v-if="isRoleEdit" class="import" icon="el-icon-download" style="float: right;">导入</el-button>
  49. </el-upload>
  50. <el-dropdown style="float: right;margin-right: 10px;">
  51. <el-button class="export" icon="el-icon-upload2">导出</el-button>
  52. <el-dropdown-menu slot="dropdown">
  53. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  54. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  55. </el-dropdown-menu>
  56. </el-dropdown>
  57. </div>
  58. <div class="table">
  59. <u-table
  60. id="table"
  61. ref="table"
  62. :key="table.tableKey"
  63. v-loading="table.listLoading"
  64. element-loading-text="给我一点时间"
  65. border
  66. fit
  67. highlight-current-row
  68. style="width: 100%;"
  69. :row-style="rowStyle"
  70. :cell-style="cellStyle"
  71. class="elTable table-fixed"
  72. row-key="id"
  73. @selection-change="handleSelectionChange"
  74. :max-height="myHeight"
  75. use-virtual
  76. @table-body-scroll="tableScroll"
  77. :row-height="rowHeight"
  78. >
  79. <u-table-column type="selection" align="center" width="50" fixed="left" />
  80. <u-table-column label="序号" type="index" align="center" width="50" fixed="left"/>
  81. <u-table-column label="饲料名称" min-width="80px" align="center" fixed="left">
  82. <template slot-scope="scope">
  83. <span>{{ scope.row.fname }}</span>
  84. </template>
  85. </u-table-column>
  86. <u-table-column label="饲料分类" min-width="80px" align="center" fixed="left">
  87. <template slot-scope="scope">
  88. <span>{{ scope.row.fclass }}</span>
  89. </template>
  90. </u-table-column>
  91. <u-table-column label="唯一编码" min-width="80px" align="center">
  92. <template slot-scope="scope">
  93. <span>{{ scope.row.feedcode }}</span>
  94. </template>
  95. </u-table-column>
  96. <u-table-column label="饲料来源" min-width="80px" align="center">
  97. <template slot-scope="scope">
  98. <span>{{ scope.row.source }}</span>
  99. </template>
  100. </u-table-column>
  101. <u-table-column label="计划类型" min-width="90px" align="center">
  102. <template slot-scope="scope">
  103. <span>{{ scope.row.printgroup }}</span>
  104. </template>
  105. </u-table-column>
  106. <u-table-column v-if="isInforvalue" label="小料秤" min-width="90px" align="center">
  107. <template slot-scope="scope">
  108. <span>{{ scope.row.smtmrname }}</span>
  109. </template>
  110. </u-table-column>
  111. <u-table-column label="允许误差数(kg)" min-width="85px" align="center">
  112. <template slot-scope="scope">
  113. <span>{{ scope.row.allowratio }}</span>
  114. </template>
  115. </u-table-column>
  116. <u-table-column label="包装单位重量(kg)" min-width="80px" align="center">
  117. <template slot-scope="scope">
  118. <span>{{ scope.row.unitweight }}</span>
  119. </template>
  120. </u-table-column>
  121. <u-table-column label="单价" min-width="50px" align="center">
  122. <template slot-scope="scope">
  123. <span>{{ scope.row.uprice }}</span>
  124. </template>
  125. </u-table-column>
  126. <u-table-column label="跳转重量域(kg)" min-width="90px" align="center">
  127. <template slot-scope="scope">
  128. <span>{{ scope.row.autozone }}</span>
  129. </template>
  130. </u-table-column>
  131. <u-table-column label="跳转延时" min-width="80px" align="center">
  132. <template slot-scope="scope">
  133. <span>{{ scope.row.autosecondname }}</span>
  134. </template>
  135. </u-table-column>
  136. <u-table-column label="确认开始" min-width="80px" align="center">
  137. <template slot-scope="scope">
  138. <span>{{ scope.row.confirmstartname }}</span>
  139. </template>
  140. </u-table-column>
  141. <u-table-column label="继电器位置" min-width="60px" align="center">
  142. <template slot-scope="scope">
  143. <span>{{ scope.row.trgaddress }}</span>
  144. </template>
  145. </u-table-column>
  146. <u-table-column label="无上域" min-width="60px" align="center">
  147. <template slot-scope="scope">
  148. <span v-if="scope.row.jmp == 0">否</span>
  149. <span v-else>是</span>
  150. </template>
  151. </u-table-column>
  152. <u-table-column label="备用字段01" min-width="90px" align="center">
  153. <template slot-scope="scope">
  154. <span>{{ scope.row.backup1 }}</span>
  155. </template>
  156. </u-table-column>
  157. <u-table-column label="备用字段02" min-width="90px" align="center">
  158. <template slot-scope="scope">
  159. <span>{{ scope.row.backup2 }}</span>
  160. </template>
  161. </u-table-column>
  162. <u-table-column label="备用字段03" min-width="90px" align="center">
  163. <template slot-scope="scope">
  164. <span>{{ scope.row.backup3 }}</span>
  165. </template>
  166. </u-table-column>
  167. <u-table-column label="是否启用" min-width="80px" align="center">
  168. <template slot-scope="scope">
  169. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  170. </template>
  171. </u-table-column>
  172. <u-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width" fixed="right">
  173. <template slot-scope="{row}">
  174. <a class="correcting" @click="handleNutritive (row)">营养价值</a>
  175. <span class="centerSpan">|</span>
  176. <a v-if="isRoleEdit" class="correcting" @click="handleRelation(row)">关联</a>
  177. <span v-if="isRoleEdit" class="centerSpan">|</span>
  178. <el-button v-if="isRoleEdit" icon="el-icon-edit-outline" class="miniSuccess" @click="handleUpdate(row)" />
  179. <span v-if="isRoleEdit" class="centerSpan">|</span>
  180. <el-button v-if="isRoleEdit" icon="el-icon-delete" class="miniDanger" @click="handleRowDelete(row)" />
  181. </template>
  182. </u-table-column>
  183. </u-table>
  184. <!-- <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" /> -->
  185. <span v-if="table.listLoading == false" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">共{{ table.total }}条</span>
  186. </div>
  187. <!-- 新增/编辑 -->
  188. <el-dialog :fullscreen="dialogFull" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="90%">
  189. <template slot="title">
  190. <div class="avue-crud__dialog__header">
  191. <span class="el-dialog__title">
  192. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  193. {{ textMap[create.dialogStatus] }}
  194. </span>
  195. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  196. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  197. <svg-icon v-else icon-class="fullscreen" />
  198. </div>
  199. </div>
  200. </template>
  201. <div class="app-add">
  202. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  203. <el-row>
  204. <el-col :span="24">
  205. <h3 style="width: 160px;text-align: right;">基础信息</h3>
  206. </el-col>
  207. </el-row>
  208. <el-row>
  209. <el-col :span="6">
  210. <el-form-item label="饲料名称:" prop="fname">
  211. <el-input ref="fname" v-model="create.temp.fname" class="filter-item" placeholder="请输入饲料名称" type="textarea" :autosize="{ minRows:1}" maxlength="32" />
  212. </el-form-item>
  213. </el-col>
  214. <el-col :span="6">
  215. <el-form-item label="饲料类别:" prop="fclassid">
  216. <el-select v-model="create.temp.fclassid" filterable placeholder="饲料类别" class="filter-item" style="width: 100%;" @change="changeFeedList">
  217. <el-option v-for="item in feedTypeList" :key="item.id" :label="item.mixname" :value="item.id" />
  218. </el-select>
  219. </el-form-item>
  220. </el-col>
  221. <el-col :span="6">
  222. <el-form-item label="唯一编码:" prop="feedcode">
  223. <el-input ref="feedcode" v-model="create.temp.feedcode" class="filter-item" placeholder="请输入唯一编码" type="text" />
  224. </el-form-item>
  225. </el-col>
  226. <el-col :span="6">
  227. <el-form-item label="饲料来源:" prop="source">
  228. <el-input ref="source" v-model="create.temp.source" class="filter-item" disabled placeholder="用户自定义" type="text" />
  229. </el-form-item>
  230. </el-col>
  231. </el-row>
  232. <el-row>
  233. <el-col :span="6">
  234. <el-form-item label="计划类型:" prop="printgroupid">
  235. <el-select v-model="create.temp.printgroupid" filterable placeholder="计划类型" class="filter-item" style="width: 100%;" @change="changePlanList">
  236. <el-option v-for="item in planTypeList" :key="item.value" :label="item.label" :value="item.value" />
  237. </el-select>
  238. </el-form-item>
  239. </el-col>
  240. <el-col :span="6">
  241. <el-form-item label="包装单位重量(kg):" prop="unitweight">
  242. <el-input ref="unitweight" v-model="create.temp.unitweight" class="filter-item" placeholder="正整数" type="number" style="width: 100%;" />
  243. </el-form-item>
  244. </el-col>
  245. <el-col :span="6">
  246. <el-form-item label="单价:" prop="uprice">
  247. <el-input ref="uprice" v-model="create.temp.uprice" class="filter-item" placeholder="最多俩位小数" type="number" step="0.01" style="width: 100%;" />
  248. </el-form-item>
  249. </el-col>
  250. </el-row>
  251. <el-row>
  252. <el-col :span="24">
  253. <h3 style="width: 160px;text-align: right;">搅拌参数</h3>
  254. </el-col>
  255. </el-row>
  256. <el-row>
  257. <el-col :span="6">
  258. <el-form-item label="允许误差数(kg):" prop="allowratio">
  259. <el-input ref="allowratio" v-model="create.temp.allowratio" class="filter-item" placeholder="正整数" type="text" />
  260. </el-form-item>
  261. </el-col>
  262. <el-col :span="6">
  263. <el-form-item label="跳转重量域(kg):" prop="autozone">
  264. <el-input ref="autozone" v-model="create.temp.autozone" :disabled="create.temp.autosecond=='0'" class="filter-item" placeholder="0-50之间的整数" type="text" />
  265. </el-form-item>
  266. </el-col>
  267. <el-col :span="6">
  268. <el-form-item label="跳转延时:" prop="autosecond">
  269. <el-select v-model="create.temp.autosecond" filterable placeholder="跳转延时" class="filter-item" style="width: 100%;" @change="changeAutosecond">
  270. <el-option v-for="item in jumpDelayList" :key="item.value" :label="item.label" :value="item.value" />
  271. </el-select>
  272. </el-form-item>
  273. </el-col>
  274. <el-col :span="6">
  275. <el-form-item label="确认开始:" prop="confirmstart">
  276. <el-select v-model="create.temp.confirmstart" filterabler placeholde="确认开始" class="filter-item" style="width: 100%;" @change="changeConfirmstart">
  277. <el-option v-for="item in confirmStartList" :key="item.id" :label="item.name" :value="item.id" />
  278. </el-select>
  279. </el-form-item>
  280. </el-col>
  281. </el-row>
  282. <el-row>
  283. <el-col :span="6">
  284. <el-form-item label="是否启用:" prop="enable">
  285. <el-select v-model="create.temp.enable" filterable placeholder="是否启用" class="filter-item" style="width: 100%;">
  286. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  287. </el-select>
  288. </el-form-item>
  289. </el-col>
  290. <el-col :span="6">
  291. <el-form-item label="继电器位置:" prop="trgaddress">
  292. <el-input ref="trgaddress" v-model="create.temp.trgaddress" class="filter-item" placeholder="继电器位置" type="number" />
  293. </el-form-item>
  294. </el-col>
  295. <el-col v-if="isInforvalue" :span="6">
  296. <el-form-item label="小料秤:" prop="smtmrid">
  297. <el-select v-model="create.temp.smtmrid" filterable placeholder="小料秤" clearable class="filter-item" style="width: 100%;" @change="changeSmallMaterial">
  298. <el-option v-for="item in smallMaterialList" :key="item.id" :label="item.tname" :value="item.id" />
  299. </el-select>
  300. </el-form-item>
  301. </el-col>
  302. <el-col :span="6">
  303. <el-form-item label="无上域:" prop="jmp">
  304. <el-select v-model="create.temp.jmp" placeholder="无上域" class="filter-item" style="width: 100%;" @change="changeSmallMaterial">
  305. <el-option v-for="item in jmpList" :key="item.id" :label="item.name" :value="item.id" />
  306. </el-select>
  307. </el-form-item>
  308. </el-col>
  309. </el-row>
  310. <el-row>
  311. <h3 style="width: 160px;text-align: right;">备用字段</h3>
  312. </el-row>
  313. <el-row>
  314. <el-col :span="6">
  315. <el-form-item label="备用字段01:" prop="backup1">
  316. <el-input ref="backup1" v-model="create.temp.backup1" class="filter-item" placeholder="备用字段01" type="text" />
  317. </el-form-item>
  318. </el-col>
  319. <el-col :span="6">
  320. <el-form-item label="备用字段02:" prop="backup2">
  321. <el-input ref="backup2" v-model="create.temp.backup2" class="filter-item" placeholder="备用字段02" type="text" />
  322. </el-form-item>
  323. </el-col>
  324. <el-col :span="6">
  325. <el-form-item label="备用字段03:" prop="backup3">
  326. <el-input ref="backup3" v-model="create.temp.backup3" class="filter-item" placeholder="备用字段03" type="text" />
  327. </el-form-item>
  328. </el-col>
  329. </el-row>
  330. </el-form>
  331. <div slot="footer" class="dialog-footer">
  332. <el-button class="cancelClose" @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  333. <el-button v-if="create.dialogStatus==='create' || create.dialogStatus==='update'" class="save" :disabled="isokDisable" @click="create.dialogStatus==='create'?createData():updateData()">确认</el-button>
  334. </div>
  335. </div>
  336. </el-dialog>
  337. <!-- 饲料库 -->
  338. <el-dialog :fullscreen="dialogFull" :visible.sync="feedBank.dialogFormVisible" :close-on-click-modal="false" width="90%">
  339. <template slot="title">
  340. <div class="avue-crud__dialog__header">
  341. <span class="el-dialog__title">
  342. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  343. {{ textMap[feedBank.dialogStatus] }}
  344. </span>
  345. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  346. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  347. <svg-icon v-else icon-class="fullscreen" />
  348. </div>
  349. </div>
  350. </template>
  351. <div class="app-add">
  352. <div class="search">
  353. <el-input v-model="feedBank.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  354. <el-select v-model="feedBank.getdataListParm.parammaps.statue" filterabler placeholder="关联状态" class="filter-item" style="width: 120px;" clearable>
  355. <el-option v-for="item in associationStatusList" :key="item.id" :label="item.name" :value="item.id" />
  356. </el-select>
  357. <el-button class="successBorder" @click="handleFeedBankSearch">查询</el-button>
  358. <el-button class="successBorder" @click="handleFeedBankRefresh">重置</el-button>
  359. </div>
  360. <div class="table">
  361. <el-table
  362. :key="feedBank.tableKey"
  363. v-loading="feedBank.listLoading"
  364. element-loading-text="给我一点时间"
  365. :data="feedBank.list"
  366. border
  367. fit
  368. highlight-current-row
  369. style="width: 100%;margin: 0 auto 50px;"
  370. :row-style="rowStyle"
  371. :cell-style="cellStyle"
  372. class="elTable table-fixed"
  373. >
  374. <el-table-column label="序号" align="center" type="index" width="50px" />
  375. <el-table-column label="来源" min-width="50" align="center">
  376. <template slot-scope="scope">
  377. <span>{{ scope.row.sources }}</span>
  378. </template>
  379. </el-table-column>
  380. <el-table-column label="中国饲料号" min-width="70px" align="center">
  381. <template slot-scope="scope">
  382. <span>{{ scope.row.feedcode }}</span>
  383. </template>
  384. </el-table-column>
  385. <el-table-column label="饲料名称" min-width="80px" align="center">
  386. <template slot-scope="scope">
  387. <span>{{ scope.row.fname }}</span>
  388. </template>
  389. </el-table-column>
  390. <el-table-column label="价格" min-width="50px" align="center">
  391. <template slot-scope="scope">
  392. <span>{{ scope.row.price }}</span>
  393. </template>
  394. </el-table-column>
  395. <el-table-column label="样品说明" min-width="50px" align="center">
  396. <template slot-scope="scope">
  397. <span>{{ scope.row.remark }}</span>
  398. </template>
  399. </el-table-column>
  400. <el-table-column label="干物质(DM%)" min-width="65px" align="center">
  401. <template slot-scope="scope">
  402. <span>{{ scope.row.dry }}</span>
  403. </template>
  404. </el-table-column>
  405. <el-table-column label="淀粉(%DM)" min-width="59px" align="center">
  406. <template slot-scope="scope">
  407. <span>{{ scope.row.starch }}</span>
  408. </template>
  409. </el-table-column>
  410. <el-table-column label="粗蛋白(CP%DM)" min-width="70px" align="center">
  411. <template slot-scope="scope">
  412. <span>{{ scope.row.cp }}</span>
  413. </template>
  414. </el-table-column>
  415. <el-table-column label="钙(Ca%DM)" min-width="85px" align="center">
  416. <template slot-scope="scope">
  417. <span>{{ scope.row.ca }}</span>
  418. </template>
  419. </el-table-column>
  420. <el-table-column label="磷(P%DM)" min-width="85px" align="center">
  421. <template slot-scope="scope">
  422. <span>{{ scope.row.p }}</span>
  423. </template>
  424. </el-table-column>
  425. <el-table-column label="产奶净能(%DM)" min-width="75px" align="center">
  426. <template slot-scope="scope">
  427. <span>{{ scope.row.n }}</span>
  428. </template>
  429. </el-table-column>
  430. <el-table-column label="脂肪(%DM)" min-width="59px" align="center">
  431. <template slot-scope="scope">
  432. <span>{{ scope.row.fat }}</span>
  433. </template>
  434. </el-table-column>
  435. <el-table-column label="ADF(%DM)" min-width="60px" align="center">
  436. <template slot-scope="scope">
  437. <span>{{ scope.row.adf }}</span>
  438. </template>
  439. </el-table-column>
  440. <el-table-column label="NDF(%DM)" min-width="60px" align="center">
  441. <template slot-scope="scope">
  442. <span>{{ scope.row.ndf }}</span>
  443. </template>
  444. </el-table-column>
  445. <el-table-column label="NDIP%" min-width="70px" align="center">
  446. <template slot-scope="scope">
  447. <span>{{ scope.row.ndip }}</span>
  448. </template>
  449. </el-table-column>
  450. <el-table-column label="粗灰分(Ash%)" min-width="65px" align="center">
  451. <template slot-scope="scope">
  452. <span>{{ scope.row.ash }}</span>
  453. </template>
  454. </el-table-column>
  455. <el-table-column label="粗料" min-width="50px" align="center">
  456. <template slot-scope="scope">
  457. <span>{{ scope.row.iscu }}</span>
  458. </template>
  459. </el-table-column>
  460. <el-table-column label="关联状态" min-width="50px" align="center">
  461. <template slot-scope="scope">
  462. <span v-if="scope.row.statue==0">否</span>
  463. <span v-if="scope.row.statue==1">是</span>
  464. </template>
  465. </el-table-column>
  466. </el-table>
  467. </div>
  468. <div slot="footer" class="dialog-footer">
  469. <el-button class="cancelClose cancelClose1" @click="feedBank.dialogFormVisible = false; ">关闭</el-button>
  470. </div>
  471. </div>
  472. </el-dialog>
  473. <!-- 关联 -->
  474. <el-dialog :fullscreen="dialogFull" :visible.sync="relation.dialogFormVisible" :close-on-click-modal="false" width="90%">
  475. <template slot="title">
  476. <div class="avue-crud__dialog__header">
  477. <span class="el-dialog__title">
  478. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  479. {{ textMap[relation.dialogStatus] }}
  480. </span>
  481. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  482. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  483. <svg-icon v-else icon-class="fullscreen" />
  484. </div>
  485. </div>
  486. </template>
  487. <div class="app-add">
  488. <div class="search">
  489. <el-input v-model="relation.getdataListParm.parammaps.fname" placeholder="饲料名称" style="width: 130px;" class="filter-item" clearable />
  490. <el-button class="successBorder" @click="handleRelationSearch">查询</el-button>
  491. </div>
  492. <div class="table">
  493. <el-table
  494. :key="relation.tableKey"
  495. v-loading="relation.listLoading"
  496. element-loading-text="给我一点时间"
  497. :data="relation.list"
  498. border
  499. fit
  500. highlight-current-row
  501. style="width: 100%;margin: 0 auto 50px;"
  502. :row-style="rowStyle"
  503. :cell-style="cellStyle"
  504. class="elTable table-fixed"
  505. >
  506. <el-table-column label="序号" align="center" type="index" width="50px" />
  507. <el-table-column label="来源" min-width="50" align="center">
  508. <template slot-scope="scope">
  509. <span>{{ scope.row.sources }}</span>
  510. </template>
  511. </el-table-column>
  512. <el-table-column label="中国饲料号" min-width="80px" align="center">
  513. <template slot-scope="scope">
  514. <span>{{ scope.row.feedcode }}</span>
  515. </template>
  516. </el-table-column>
  517. <el-table-column label="饲料名称" min-width="80px" align="center">
  518. <template slot-scope="scope">
  519. <span>{{ scope.row.fname }}</span>
  520. </template>
  521. </el-table-column>
  522. <el-table-column label="价格" min-width="50px" align="center">
  523. <template slot-scope="scope">
  524. <span>{{ scope.row.price }}</span>
  525. </template>
  526. </el-table-column>
  527. <el-table-column label="样品说明" min-width="50px" align="center">
  528. <template slot-scope="scope">
  529. <span>{{ scope.row.remark }}</span>
  530. </template>
  531. </el-table-column>
  532. <el-table-column label="干物质(DM%)" min-width="65px" align="center">
  533. <template slot-scope="scope">
  534. <span>{{ scope.row.dry }}</span>
  535. </template>
  536. </el-table-column>
  537. <el-table-column label="淀粉(%DM)" min-width="59px" align="center">
  538. <template slot-scope="scope">
  539. <span>{{ scope.row.starch }}</span>
  540. </template>
  541. </el-table-column>
  542. <el-table-column label="粗蛋白(CP%DM)" min-width="75px" align="center">
  543. <template slot-scope="scope">
  544. <span>{{ scope.row.cp }}</span>
  545. </template>
  546. </el-table-column>
  547. <el-table-column label="钙(Ca%DM)" min-width="83px" align="center">
  548. <template slot-scope="scope">
  549. <span>{{ scope.row.ca }}</span>
  550. </template>
  551. </el-table-column>
  552. <el-table-column label="磷(P%DM)" min-width="80px" align="center">
  553. <template slot-scope="scope">
  554. <span>{{ scope.row.p }}</span>
  555. </template>
  556. </el-table-column>
  557. <el-table-column label="产奶净能(%DM)" min-width="75px" align="center">
  558. <template slot-scope="scope">
  559. <span>{{ scope.row.n }}</span>
  560. </template>
  561. </el-table-column>
  562. <el-table-column label="脂肪(%DM)" min-width="59px" align="center">
  563. <template slot-scope="scope">
  564. <span>{{ scope.row.fat }}</span>
  565. </template>
  566. </el-table-column>
  567. <el-table-column label="ADF(%DM)" min-width="60px" align="center">
  568. <template slot-scope="scope">
  569. <span>{{ scope.row.adf }}</span>
  570. </template>
  571. </el-table-column>
  572. <el-table-column label="NDF(%DM)" min-width="60px" align="center">
  573. <template slot-scope="scope">
  574. <span>{{ scope.row.ndf }}</span>
  575. </template>
  576. </el-table-column>
  577. <el-table-column label="NDIP%" min-width="70px" align="center">
  578. <template slot-scope="scope">
  579. <span>{{ scope.row.ndip }}</span>
  580. </template>
  581. </el-table-column>
  582. <el-table-column label="粗灰分(Ash%)" min-width="65px" align="center">
  583. <template slot-scope="scope">
  584. <span>{{ scope.row.ash }}</span>
  585. </template>
  586. </el-table-column>
  587. <el-table-column label="粗料" min-width="50px" align="center">
  588. <template slot-scope="scope">
  589. <span>{{ scope.row.iscu }}</span>
  590. </template>
  591. </el-table-column>
  592. <el-table-column label="操作" min-width="50px" align="center" class-name="small-padding fixed-width" fixed="right">
  593. <template slot-scope="{row}">
  594. <a v-if="row.statueRelation == '1'" class="correcting" :disabled="isokDisable" @click="disassociateData(row)">取消关联</a>
  595. <a v-if="row.statueRelation == '0'" class="correcting" :disabled="isokDisable" @click="relationData(row)">关联</a>
  596. </template>
  597. </el-table-column>
  598. </el-table>
  599. </div>
  600. <div slot="footer" class="dialog-footer">
  601. <el-button class="cancelClose cancelClose1" @click="relation.dialogFormVisible = false;getList() ">关闭</el-button>
  602. </div>
  603. </div>
  604. </el-dialog>
  605. <!-- 营养价值 -->
  606. <el-dialog :fullscreen="dialogFull" :visible.sync="nutritive.dialogFormVisible" :close-on-click-modal="false" width="90%">
  607. <template slot="title">
  608. <div class="avue-crud__dialog__header">
  609. <span class="el-dialog__title">
  610. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  611. {{ textMap[nutritive.dialogStatus] }}
  612. </span>
  613. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  614. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  615. <svg-icon v-else icon-class="fullscreen" />
  616. </div>
  617. </div>
  618. </template>
  619. <div class="app-add">
  620. <el-form ref="temp" :rules="nutritive.rules" :model="nutritive.temp" label-position="right" label-width="160px" style="width: 100%;margin:0 auto 50px">
  621. <el-row>
  622. <el-col :span="6">
  623. <el-form-item label="干物质(DM%):" prop="dry">
  624. <el-input ref="dry" v-model="nutritive.temp.dry" :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入干物质" type="number" step="0.01" />
  625. </el-form-item>
  626. </el-col>
  627. <el-col :span="6">
  628. <el-form-item label="淀粉(%DM):" prop="starch">
  629. <el-input ref="starch" v-model="nutritive.temp.starch" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入淀粉" type="number" step="0.01" />
  630. </el-form-item>
  631. </el-col>
  632. <el-col :span="6">
  633. <el-form-item label="粗蛋白(CP%DM):" prop="cp">
  634. <el-input ref="cp" v-model="nutritive.temp.cp" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗蛋白" type="number" step="0.01" />
  635. </el-form-item>
  636. </el-col>
  637. <el-col :span="6">
  638. <el-form-item label="钙(Ca%DM):" prop="ca">
  639. <el-input ref="ca" v-model="nutritive.temp.ca" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入钙" type="number" step="0.01" />
  640. </el-form-item>
  641. </el-col>
  642. </el-row>
  643. <el-row>
  644. <el-col :span="6">
  645. <el-form-item label="磷(P%DM):" prop="p">
  646. <el-input ref="p" v-model="nutritive.temp.p" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入磷" type="number" step="0.01" />
  647. </el-form-item>
  648. </el-col>
  649. <el-col :span="6">
  650. <el-form-item label="产奶净能(%DM):" prop="n">
  651. <el-input ref="n" v-model="nutritive.temp.n" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入产奶净能" type="number" step="0.01" />
  652. </el-form-item>
  653. </el-col>
  654. <el-col :span="6">
  655. <el-form-item label="脂肪(%DM):" prop="fat">
  656. <el-input ref="fat" v-model="nutritive.temp.fat" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入脂肪" type="number" step="0.01" />
  657. </el-form-item>
  658. </el-col>
  659. <el-col :span="6">
  660. <el-form-item label="ADF(%DM):" prop="adf">
  661. <el-input ref="adf" v-model="nutritive.temp.adf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入ADF" type="number" step="0.01" />
  662. </el-form-item>
  663. </el-col>
  664. </el-row>
  665. <el-row>
  666. <el-col :span="6">
  667. <el-form-item label="NDF(%DM):" prop="ndf">
  668. <el-input ref="ndf" v-model="nutritive.temp.ndf" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDF" type="number" step="0.01" />
  669. </el-form-item>
  670. </el-col>
  671. <el-col :span="6">
  672. <el-form-item label="NDIP(%):" prop="ndip">
  673. <el-input ref="ndip" v-model="nutritive.temp.ndip" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入NDIP" type="number" step="0.01" />
  674. </el-form-item>
  675. </el-col>
  676. <el-col :span="6">
  677. <el-form-item label="粗灰分(Ash%):" prop="ash">
  678. <el-input ref="ash" v-model="nutritive.temp.ash" v-limit :disabled="isRoleEdit==false" class="filter-item" placeholder="请输入粗灰分" type="number" min="0.00" step="0.01" />
  679. </el-form-item>
  680. </el-col>
  681. </el-row>
  682. </el-form>
  683. <div slot="footer" class="dialog-footer">
  684. <el-button class="cancelClose" @click="nutritive.dialogFormVisible = false;getList()">关闭</el-button>
  685. <el-button v-if="nutritive.dialogStatus==='nutritive' && isRoleEdit" class="save" :disabled="isokDisable" @click="nutritiveData()">确认</el-button>
  686. </div>
  687. </div>
  688. </el-dialog>
  689. </div>
  690. </template>
  691. <script>
  692. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, GetDataByNames, checkButtons } from '@/api/common'
  693. import Cookies from 'js-cookie'
  694. import Sortable from 'sortablejs'
  695. import Pagination from '@/components/Pagination'
  696. import axios from 'axios'
  697. import { getToken } from '@/utils/auth'
  698. import { parseTime, json2excel, handleTableSpan, handleObjectSpanMethod } from '@/utils/index.js'
  699. import { MessageBox } from 'element-ui'
  700. export default {
  701. name: 'FeedTable',
  702. components: { Pagination },
  703. directives: {
  704. limit: {
  705. // 指令的定义
  706. update: function(el) {
  707. el.onkeypress = function(e) {
  708. var code = e.charCode
  709. if (code != 0) {
  710. if (!String.fromCharCode(code).match(/[0-9\.]/)) {
  711. return false
  712. }
  713. }
  714. }
  715. el.addEventListener('textInput', function(e) {
  716. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  717. })
  718. el.onkeyup = function(e) {
  719. e.target.value = e.target.value.replace(/[^0-9\.]/g, '')
  720. }
  721. }
  722. }
  723. },
  724. data() {
  725. return {
  726. rowHeight: 30,
  727. dialogFull: false,
  728. isInforvalue: false,
  729. isRoleEdit: [],
  730. download: {
  731. getdataListParm: {
  732. name: 'getFeedList',
  733. page: 1,
  734. offset: 1,
  735. pagecount: 0,
  736. returntype: 'Map',
  737. parammaps: {
  738. pastureid: Cookies.get('pastureid'),
  739. fname: '',
  740. fclassid: '',
  741. source: '',
  742. autozone: '',
  743. autosecond: '',
  744. allowratio: '',
  745. printgroup: '',
  746. enable: ''
  747. }
  748. },
  749. list: []
  750. },
  751. requestParams: [
  752. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['跳转延时'] },
  753. { name: 'getFeedclassByBig', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }},
  754. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['计划类型'] },
  755. { name: 'getTMRListEnableTypeFeed', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid'), eqtype: '4' }}
  756. ],
  757. requestParams2: {
  758. name: 'getSysoptEnable', offset: 0, parammaps: { pastureid: Cookies.get('pastureid'), inforname: 'isSmallMaterial' }
  759. },
  760. enableList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 是否启用
  761. feedSourcesList: [{ id: '0', name: '系统内置' }, { id: '1', name: '用户自定义' }], // 饲料来源
  762. confirmStartList: [{ id: '0', name: '禁用' }, { id: '1', name: '启用' }], // 确认开始
  763. associationStatusList: [{ id: '1', name: '是' }, { id: '0', name: '否' }], // 关联状态
  764. jumpDelayList: [], // 跳转延时
  765. feedTypeList: [], // 饲料分类
  766. planTypeList: [], // 计划类型
  767. smallMaterialList: [], // 小料秤
  768. jmpList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 无上域
  769. table: {
  770. tableKey: 0,
  771. list: [],
  772. total: 0,
  773. listLoading: true,
  774. getdataListParm: {
  775. name: 'getFeedList',
  776. page: 1,
  777. offset: 1,
  778. pagecount: '',
  779. returntype: 'Map',
  780. parammaps: {
  781. pastureid: Cookies.get('pastureid'),
  782. fname: '',
  783. fclassid: '',
  784. source: '',
  785. autozone: '',
  786. autosecond: '',
  787. allowratio: '',
  788. printgroup: '',
  789. enable: ''
  790. }
  791. }
  792. },
  793. // 多项搜索显示隐藏
  794. arrowDown: true,
  795. arrowUp: false,
  796. // 新增/编辑
  797. create: {
  798. dialogFormVisible: false,
  799. dialogStatus: '',
  800. temp: { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '' },
  801. rules: {
  802. printgroupid :[{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  803. fname: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  804. fclassid: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }],
  805. feedcode: [{ type: 'string', required: true, message: '必填', trigger: 'blur' }]
  806. }
  807. },
  808. // 饲料库
  809. feedBank: {
  810. dialogFormVisible: false,
  811. dialogStatus: '',
  812. temp: {},
  813. rules: {},
  814. tableKey: 0,
  815. list: [],
  816. total: 0,
  817. listLoading: true,
  818. getdataListParm: {
  819. name: 'getFeednurList',
  820. page: 1,
  821. offset: 1,
  822. returntype: 'Map',
  823. parammaps: {
  824. pastureid: Cookies.get('pastureid'),
  825. fname: '',
  826. statue: ''
  827. }
  828. }
  829. },
  830. // 关联
  831. relation: {
  832. dialogFormVisible: false,
  833. dialogStatus: '',
  834. temp: {},
  835. rules: {},
  836. tableKey: 0,
  837. list: [],
  838. total: 0,
  839. listLoading: true,
  840. getdataListParm: {
  841. name: 'getFeednurRelation',
  842. page: 1,
  843. offset: 1,
  844. returntype: 'Map',
  845. parammaps: {
  846. pastureid: Cookies.get('pastureid'),
  847. fname: ''
  848. }
  849. }
  850. },
  851. // 营养价值
  852. nutritive: {
  853. dialogFormVisible: false,
  854. dialogStatus: '',
  855. temp: {},
  856. rules: {}
  857. },
  858. textMap: {
  859. create: '新增',
  860. update: '编辑',
  861. feedBank: '饲料库',
  862. relation: '关联',
  863. nutritive: '营养价值'
  864. },
  865. isokDisable: false,
  866. selectList: [],
  867. requestParam: {},
  868. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  869. cellStyle: { padding: 0 + 'px' },
  870. dropState: false,
  871. isOrder: true,
  872. myHeight:document.documentElement.clientHeight - 85- 150
  873. }
  874. },
  875. computed: {
  876. // 设置请求头
  877. headers() {
  878. return {
  879. token: getToken()
  880. }
  881. },
  882. uploadData() {
  883. return {
  884. name: 'checkFeedName,checkProjectType, checkFeedCode, checkFeedType, importFeed,updateFeedSortByCode',
  885. importParams: '饲料名称,饲料类别,唯一编码,计划类型,包装单位重量,单价,允许误差数,跳转延时,确认开始,是否启用,继电器位置,无上域',
  886. sheetname: 'Sheet1',
  887. // 登录牧场
  888. pastureid: Cookies.get('pastureid'),
  889. // 日期参数
  890. dateParams: '',
  891. // 必填参数
  892. requiredParams: '饲料名称,饲料分类',
  893. // 为数值的参数
  894. numParams: ''
  895. }
  896. },
  897. // 设置上传地址
  898. uploadExcelUrl() {
  899. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  900. }
  901. },
  902. mounted() {
  903. document.addEventListener('click', (e) => {
  904. if (this.$refs.selectInput !== undefined) {
  905. if (!this.$refs.selectInput.contains(e.target)) {
  906. this.arrowDown = true
  907. this.arrowUp = false
  908. } else {
  909. this.arrowDown = false
  910. this.arrowUp = true
  911. }
  912. }
  913. })
  914. },
  915. created() {
  916. this.getList()
  917. this.getDownList()
  918. this.getButtons()
  919. this.getInforvalueList()
  920. },
  921. methods: {
  922. beforeImport(file) {
  923. const isLt2M = file.size / 1024 / 1024 < 2
  924. if (!isLt2M) {
  925. this.$message.error('上传文件大小不能超过 2MB!')
  926. }
  927. return isLt2M
  928. },
  929. handleImportSuccess(res, file) {
  930. this.getList()
  931. if (res.msg === 'ok') {
  932. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  933. if (res.data.err_count > 0) {
  934. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  935. import('@/vendor/Export2Excel').then(excel => {
  936. const list1 = res.data.result
  937. const tHeader = [
  938. '饲料名称', '饲料分类', '唯一编码', '计划类型', '允许误差数(kg)', '包装单位重量(kg)', '单价', '跳转重量域(kg)', '跳转延时', '确认开始', '继电器位置', '无上域', '备用字段01', '备用字段02', '备用字段03', '错误信息'
  939. ]
  940. const filterVal = [
  941. '饲料名称', '饲料分类', '唯一编码', '计划类型', '允许误差数(kg)', '包装单位重量(kg)', '单价', '跳转重量域(kg)', '跳转延时', '确认开始', '继电器位置', '无上域', '备用字段01', '备用字段02', '备用字段03', 'error_msg'
  942. ]
  943. const data1 = this.formatJson(filterVal, list1)
  944. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '饲料表导入报错信息', autoWidth: true, bookType: 'xlsx' })
  945. })
  946. }
  947. } else {
  948. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  949. }
  950. },
  951. formatJson(filterVal, jsonData) {
  952. return jsonData.map(v =>
  953. filterVal.map(j => {
  954. if (j === 'timestamp') {
  955. return parseTime(v[j])
  956. } else {
  957. return v[j]
  958. }
  959. })
  960. )
  961. },
  962. handleExport(item) {
  963. if (item == 1) {
  964. console.log('点击了导出模板')
  965. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  966. console.log('点击了导出模板',this.download.getdataListParm)
  967. GetDataByName(this.download.getdataListParm).then(response => {
  968. if (response.data.list !== null) {
  969. this.download.list = response.data.list
  970. } else {
  971. this.download.list = []
  972. }
  973. console.log(this.download.list)
  974. var downloadList = [
  975. { 'obj1': '1、文件类型为xlsx类型,对应表格文件名格式为:文件名称.xlsx;' },
  976. { 'obj1': '2、底部工作表名称不可更改,默认为:Sheet1;' },
  977. // { 'obj1': '3、栏舍名称,实际牛头数,系数(%),系数头数,配方模板,补料配方字体为必填;' },
  978. // { 'obj1': '4、第一列栏舍名称默认为系统中栏舍,不可修改;' },
  979. // { 'obj1': '5、实际牛头数为正整数,系数为正数,至多保留俩位小数;' },
  980. // { 'obj1': '6、配方模板名称必须与系统中配方计划—配方模板中的饲喂配方匹配;若补料配方开启,需与配方模板中的补料配方匹配;' },
  981. // { 'obj1': '7、数据最多可导入200条,超过200条请分多个文件导入。' }
  982. ]
  983. var excelDatas = [
  984. {
  985. tHeader: [
  986. '饲料名称', '饲料分类', '唯一编码', '饲料来源', '计划类型', '允许误差数(kg)', '包装单位重量(kg)', '单价', '跳转重量域(kg)', '跳转延时', '确认开始', '继电器位置', '无上域', '备用字段01', '备用字段02', '备用字段03'
  987. ],
  988. filterVal: ['', '', '', '', '','', '', '', '', '', '', '', '', '', '', ''],
  989. tableDatas: this.download.list,
  990. sheetName: 'Sheet1'
  991. }, {
  992. tHeader: ['填写规范:'],
  993. filterVal: ['obj1'],
  994. tableDatas: downloadList,
  995. sheetName: 'Sheet2'
  996. }
  997. ]
  998. json2excel(excelDatas, '饲料表导入模板', true, 'xlsx')
  999. })
  1000. // console.log('点击了导出模板')
  1001. // const requestParam = this.requestParam
  1002. // const url = process.env.VUE_APP_BASE_API + 'file/导入导出模板/库存管理/饲料表导入模板.xlsx' // 请求下载文件的地址
  1003. // console.log(url)
  1004. // axios({
  1005. // method: 'GET',
  1006. // url: url,
  1007. // data: requestParam,
  1008. // headers: { token: getToken(), optname: 'insertcustomdoc' },
  1009. // responseType: 'blob'
  1010. // }).then(res => {
  1011. // if (!res) return
  1012. // this.percentage = 99
  1013. // setTimeout(() => {
  1014. // this.isPercentage = false
  1015. // }, 2000)
  1016. // const blob = new Blob([res.data], {
  1017. // type: 'application/octet-stream;charset=utf-8'
  1018. // })
  1019. // const url = window.URL.createObjectURL(blob)
  1020. // const aLink = document.createElement('a')
  1021. // aLink.style.display = 'none'
  1022. // aLink.href = url
  1023. // const docname = '饲料表导入模板.xlsx'
  1024. // aLink.setAttribute('download', docname) // 下载的文件
  1025. // document.body.appendChild(aLink)
  1026. // aLink.click()
  1027. // document.body.removeChild(aLink)
  1028. // window.URL.revokeObjectURL(url)
  1029. // })
  1030. } else {
  1031. console.log('点击了导出数据')
  1032. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1033. GetDataByName(this.download.getdataListParm).then(response => {
  1034. if (response.data.list !== null) {
  1035. this.download.list = response.data.list
  1036. } else {
  1037. this.download.list = []
  1038. }
  1039. var excelDatas = [
  1040. {
  1041. tHeader: [
  1042. '饲料名称', '饲料分类', '唯一编码', '饲料来源', '计划类型', '允许误差数(kg)', '包装单位重量(kg)', '单价', '跳转重量域(kg)', '跳转延时', '确认开始', '继电器位置', '无上域', '备用字段01', '备用字段02', '备用字段03'
  1043. ],
  1044. filterVal: ['fname', 'fclass', 'feedcode', 'source', 'printgroup', 'allowratio', 'unitweight', 'uprice', 'autozone', 'autosecondnam', 'onfirmstartname', 'trgaddress', 'jmp', 'backup1', 'backup2', 'backup3'],
  1045. tableDatas: this.download.list,
  1046. sheetName: 'Sheet1'
  1047. }
  1048. ]
  1049. json2excel(excelDatas, '饲料表', true, 'xlsx')
  1050. })
  1051. }
  1052. },
  1053. getButtons() {
  1054. const Edit = 'FeedTable'
  1055. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  1056. this.isRoleEdit = isRoleEdit
  1057. },
  1058. getInforvalueList() {
  1059. GetDataByName(this.requestParams2).then(response => {
  1060. if (response.data !== null) {
  1061. if (response.data.list[0].inforvalue == 0) {
  1062. this.isInforvalue = false
  1063. } else {
  1064. this.isInforvalue = true
  1065. }
  1066. } else {
  1067. this.isInforvalue = false
  1068. }
  1069. })
  1070. },
  1071. getDownList() {
  1072. GetDataByNames(this.requestParams).then(response => {
  1073. this.jumpDelayList = response.data.getDictByName.list
  1074. this.feedTypeList = response.data.getFeedclassByBig.list
  1075. this.planTypeList = response.data.getDictByName2.list
  1076. this.smallMaterialList = response.data.getTMRListEnableTypeFeed.list
  1077. })
  1078. },
  1079. getList() {
  1080. this.table.listLoading = true
  1081. GetDataByName(this.table.getdataListParm).then(response => {
  1082. console.log('table数据', response.data.list)
  1083. if (response.data.list !== null) {
  1084. this.table.list = response.data.list
  1085. this.table.pageNum = response.data.pageNum
  1086. this.table.pageSize = response.data.pageSize
  1087. } else {
  1088. this.table.list = []
  1089. }
  1090. this.$refs.table.reloadData( this.table.list)
  1091. this.table.total = response.data.total
  1092. setTimeout(() => {
  1093. this.table.listLoading = false
  1094. }, 100)
  1095. })
  1096. },
  1097. tableScroll ({scrollTop, scrollLeft, table, judgeFlse}) {
  1098. // {scrollTop, scrollLeft, table, judgeFlse: 这个参数返回一个boolean值,为true则代表表格滚动到了底部了,false没有滚动到底部,必须开起大数据渲染模式才能有值哦}, event
  1099. console.log(scrollTop, scrollLeft, table, judgeFlse)
  1100. },
  1101. handleSearch() {
  1102. console.log('点击了查询')
  1103. this.table.getdataListParm.offset = 1
  1104. this.getList()
  1105. this.arrowDown = true
  1106. this.arrowUp = false
  1107. },
  1108. handleRefresh() {
  1109. console.log('点击了重置')
  1110. this.table.getdataListParm.parammaps.fname = ''
  1111. this.table.getdataListParm.parammaps.fclassid = ''
  1112. this.table.getdataListParm.parammaps.source = ''
  1113. this.table.getdataListParm.parammaps.autozone = ''
  1114. this.table.getdataListParm.parammaps.autosecond = ''
  1115. this.table.getdataListParm.parammaps.allowratio = ''
  1116. this.table.getdataListParm.parammaps.printgroup = ''
  1117. this.table.getdataListParm.parammaps.enable = ''
  1118. this.table.getdataListParm.offset = 1
  1119. this.getList()
  1120. },
  1121. resetTemp() {
  1122. this.create.temp = { pastureid: Cookies.get('pastureid'), fname: '', fclassid: '', fclass: '', feedcode: '', source: '用户自定义', printgroupid: '1', printgroup: '无', unitweight: '', uprice: '', allowratio: '', autozone: '', autosecond: '0', autosecondname: '禁用', confirmstart: '0', confirmstartname: '禁用', enable: '1', trgaddress: '', backup1: '', backup2: '', backup3: '', jmp: '0' }
  1123. },
  1124. // 计划类型
  1125. changePlanList(item) {
  1126. console.log(item, '======')
  1127. this.create.temp.printgroup = this.planTypeList.find(obj => obj.value === item).label
  1128. },
  1129. // 饲料类型
  1130. changeFeedList(item) {
  1131. this.create.temp.fclass = this.feedTypeList.find(obj => obj.id === item).mixname
  1132. },
  1133. // 跳转延时
  1134. changeAutosecond(item) {
  1135. this.create.temp.autosecondname = this.jumpDelayList.find(obj => obj.value === item).label
  1136. },
  1137. // 确认开始
  1138. changeConfirmstart(item) {
  1139. this.create.temp.confirmstartname = this.confirmStartList.find(obj => obj.id === item).name
  1140. },
  1141. changeSmallMaterial(item) {
  1142. if (item !== '') {
  1143. this.create.temp.smtmrname = this.smallMaterialList.find(obj => obj.id === item).tname
  1144. } else {
  1145. this.create.temp.smtmrname = ''
  1146. }
  1147. },
  1148. // 新增
  1149. handleCreate() {
  1150. console.log('点击了新增')
  1151. this.resetTemp()
  1152. this.dialogFull = false
  1153. this.create.dialogStatus = 'create'
  1154. this.create.dialogFormVisible = true
  1155. },
  1156. createData() {
  1157. console.log('点击了新增保存')
  1158. this.isokDisable = true
  1159. setTimeout(() => {
  1160. this.isokDisable = false
  1161. }, 1000)
  1162. this.$refs['temp'].validate(valid => {
  1163. if (valid) {
  1164. const unitweight = /^[1-9]\d*$/
  1165. if (this.create.temp.unitweight !== '') {
  1166. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  1167. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  1168. return false
  1169. }
  1170. }
  1171. // const uprice = /^\d+(\.\d{1,2})?$/
  1172. const uprice = /^(\d+|\d+\.\d{1,2})$/
  1173. if (this.create.temp.uprice !== '') {
  1174. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  1175. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  1176. return false
  1177. }
  1178. }
  1179. if (this.create.temp.autozone !== '') {
  1180. const autozone = /^([0-9]|(1[0-9]|2[0-9]|3[0-9]|4[0-9]|(50)))$/
  1181. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  1182. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于50的整数', duration: 2000 })
  1183. return false
  1184. }
  1185. } else {
  1186. this.create.temp.autozone = '0'
  1187. }
  1188. if (this.create.temp.trgaddress.length > 8) {
  1189. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  1190. return false
  1191. }
  1192. const allowratio = /^[0-9]\d*$/
  1193. if (this.create.temp.allowratio !== '') {
  1194. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  1195. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  1196. return false
  1197. }
  1198. }
  1199. this.isokDisable = true
  1200. setTimeout(() => {
  1201. this.isokDisable = false
  1202. }, 1000)
  1203. this.requestParam.name = 'insertFeed'
  1204. this.requestParam.parammaps = this.create.temp
  1205. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  1206. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  1207. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  1208. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  1209. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  1210. PostDataByName(this.requestParam).then(response => {
  1211. console.log('新增保存发送参数', this.requestParam)
  1212. if (response.msg !== 'fail') {
  1213. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1214. this.create.dialogFormVisible = false
  1215. this.getList()
  1216. } else {
  1217. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1218. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  1219. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  1220. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  1221. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  1222. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  1223. }
  1224. })
  1225. }
  1226. })
  1227. },
  1228. // 编辑
  1229. handleUpdate(row) {
  1230. console.log('点击了编辑', row)
  1231. this.create.dialogStatus = 'update'
  1232. this.dialogFull = false
  1233. this.create.dialogFormVisible = true
  1234. row.fclassid = String(row.fclassid)
  1235. row.printgroupid = String(row.printgroupid)
  1236. row.autosecond = String(row.autosecond)
  1237. row.confirmstart = String(row.confirmstart)
  1238. row.enable = String(row.enable)
  1239. row.jmp = String(row.jmp)
  1240. if (row.printgroupid !== '') {
  1241. row.printgroup = this.planTypeList.find(obj => obj.value == row.printgroupid).label
  1242. }
  1243. this.create.temp = Object.assign({}, row)
  1244. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  1245. if (this.create.temp.uprice == '0.00') { this.create.temp.uprice = '' }
  1246. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  1247. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  1248. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  1249. if (this.create.temp.smtmrid == '-1') { this.create.temp.smtmrid = '' }
  1250. console.log(this.create.temp, '=====123')
  1251. },
  1252. updateData() {
  1253. console.log('点击了编辑保存')
  1254. this.isokDisable = true
  1255. setTimeout(() => {
  1256. this.isokDisable = false
  1257. }, 1000)
  1258. this.$refs['temp'].validate(valid => {
  1259. if (valid) {
  1260. const unitweight = /^[1-9]\d*$/
  1261. if (this.create.temp.unitweight !== '') {
  1262. if (!unitweight.test(parseFloat(this.create.temp.unitweight))) {
  1263. this.$message({ type: 'error', message: '包装单位重量请输入正整数', duration: 2000 })
  1264. return false
  1265. }
  1266. }
  1267. // const uprice = /^\d+(\.\d{1,2})?$/
  1268. const uprice = /^(\d+|\d+\.\d{1,2})$/
  1269. if (this.create.temp.uprice !== '') {
  1270. if (!uprice.test(parseFloat(this.create.temp.uprice))) {
  1271. this.$message({ type: 'error', message: '单价请保留两位小数', duration: 2000 })
  1272. return false
  1273. }
  1274. }
  1275. if (this.create.temp.autozone !== '') {
  1276. const autozone = /^([0-9]|(1[0-9]|2[0-9]|3[0-9]|4[0-9]|(50)))$/
  1277. if (!autozone.test(parseFloat(this.create.temp.autozone))) {
  1278. this.$message({ type: 'error', message: '跳转重量域请输入大于等于0小于等于50的整数', duration: 2000 })
  1279. return false
  1280. }
  1281. } else {
  1282. this.create.temp.autozone = '0'
  1283. }
  1284. if (this.create.temp.trgaddress.length > 8) {
  1285. this.$message({ type: 'error', message: '继电器位置请输入1-8位数字', duration: 2000 })
  1286. return false
  1287. }
  1288. const allowratio = /^[0-9]\d*$/
  1289. if (this.create.temp.allowratio !== '') {
  1290. if (!allowratio.test(parseFloat(this.create.temp.allowratio))) {
  1291. this.$message({ type: 'error', message: '允许误差数请输入大于等于0的整数', duration: 2000 })
  1292. return false
  1293. }
  1294. }
  1295. this.isokDisable = true
  1296. setTimeout(() => {
  1297. this.isokDisable = false
  1298. }, 1000)
  1299. this.requestParam.name = 'updateFeed'
  1300. this.requestParam.parammaps = this.create.temp
  1301. if (this.create.temp.allowratio == '') { this.create.temp.allowratio = '0' }
  1302. if (this.create.temp.uprice == '') { this.create.temp.uprice = '0' }
  1303. if (this.create.temp.unitweight == '') { this.create.temp.unitweight = '0' }
  1304. if (this.create.temp.autozone == '') { this.create.temp.autozone = '0' }
  1305. if (this.create.temp.trgaddress == '') { this.create.temp.trgaddress = '0' }
  1306. PostDataByName(this.requestParam).then(response => {
  1307. console.log('新增保存发送参数', this.requestParam)
  1308. if (response.msg !== 'fail') {
  1309. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1310. this.create.dialogFormVisible = false
  1311. this.getList()
  1312. } else {
  1313. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1314. if (this.create.temp.allowratio == '0') { this.create.temp.allowratio = '' }
  1315. if (this.create.temp.uprice == '0') { this.create.temp.uprice = '' }
  1316. if (this.create.temp.unitweight == '0') { this.create.temp.unitweight = '' }
  1317. if (this.create.temp.autozone == '0') { this.create.temp.autozone = '' }
  1318. if (this.create.temp.trgaddress == '0') { this.create.temp.trgaddress = '' }
  1319. }
  1320. })
  1321. }
  1322. })
  1323. },
  1324. // 饲料库
  1325. handleFeedBank() {
  1326. console.log('点击了饲料库')
  1327. this.dialogFull = false
  1328. this.feedBank.dialogStatus = 'feedBank'
  1329. this.feedBank.dialogFormVisible = true
  1330. this.getFeedBankList()
  1331. },
  1332. getFeedBankList() {
  1333. this.feedBank.listLoading = true
  1334. GetDataByName(this.feedBank.getdataListParm).then(response => {
  1335. console.log('table数据', response.data.list)
  1336. if (response.data.list !== null) {
  1337. this.feedBank.list = response.data.list
  1338. this.feedBank.pageNum = response.data.pageNum
  1339. this.feedBank.pageSize = response.data.pageSize
  1340. this.feedBank.total = response.data.total
  1341. } else {
  1342. this.feedBank.list = []
  1343. }
  1344. setTimeout(() => {
  1345. this.feedBank.listLoading = false
  1346. }, 100)
  1347. })
  1348. },
  1349. handleFeedBankSearch() {
  1350. console.log('点击了饲料库搜索')
  1351. this.getFeedBankList()
  1352. this.feedBank.getdataListParm.offset = 1
  1353. },
  1354. handleFeedBankRefresh() {
  1355. console.log('点击了饲料库重置')
  1356. this.feedBank.getdataListParm.parammaps.fname = ''
  1357. this.feedBank.getdataListParm.parammaps.statue = ''
  1358. this.getFeedBankList()
  1359. },
  1360. // 关联
  1361. handleRelation(row) {
  1362. console.log('点击了关联')
  1363. this.dialogFull = false
  1364. this.relation.dialogStatus = 'relation'
  1365. this.relation.dialogFormVisible = true
  1366. this.relation.temp = Object.assign({}, row)
  1367. this.relation.getdataListParm.parammaps.fid = this.relation.temp.id
  1368. this.getRelationList()
  1369. },
  1370. getRelationList() {
  1371. this.relation.listLoading = true
  1372. GetDataByName(this.relation.getdataListParm).then(response => {
  1373. console.log('table数据', response.data.list)
  1374. if (response.data.list !== null) {
  1375. this.relation.list = response.data.list
  1376. this.relation.pageNum = response.data.pageNum
  1377. this.relation.pageSize = response.data.pageSize
  1378. this.relation.total = response.data.total
  1379. } else {
  1380. this.relation.list = []
  1381. }
  1382. setTimeout(() => {
  1383. this.relation.listLoading = false
  1384. }, 100)
  1385. })
  1386. },
  1387. handleRelationSearch() {
  1388. console.log('点击了关联搜索')
  1389. this.relation.getdataListParm.offset = 1
  1390. this.getRelationList()
  1391. },
  1392. disassociateData(row) {
  1393. console.log('点击了取消关联')
  1394. MessageBox.confirm('是否确认取消关联?', {
  1395. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1396. }).then(() => {
  1397. this.isokDisable = true
  1398. setTimeout(() => {
  1399. this.isokDisable = false
  1400. }, 1000)
  1401. this.requestParam.name = 'updateFeedrelation'
  1402. this.requestParam.parammaps = {}
  1403. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1404. this.requestParam.parammaps.fid = this.relation.temp.id
  1405. this.requestParam.parammaps.id = row.id
  1406. PostDataByName(this.requestParam).then(response => {
  1407. console.log('取消关联保存发送参数', this.requestParam)
  1408. if (response.msg !== 'fail') {
  1409. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1410. this.getRelationList()
  1411. this.getList()
  1412. } else {
  1413. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1414. }
  1415. })
  1416. }).catch(() => {
  1417. this.$message({ type: 'info', message: '已取消' })
  1418. })
  1419. },
  1420. relationData(row) {
  1421. console.log('点击了关联保存')
  1422. MessageBox.confirm('是否确认关联?', {
  1423. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1424. }).then(() => {
  1425. this.isokDisable = true
  1426. setTimeout(() => {
  1427. this.isokDisable = false
  1428. }, 1000)
  1429. this.requestParam.name = 'insertFeednur'
  1430. this.requestParam.parammaps = {}
  1431. this.requestParam.parammaps.pastureid = this.relation.temp.pastureid
  1432. this.requestParam.parammaps.fid = this.relation.temp.id
  1433. this.requestParam.parammaps.fname = this.relation.temp.fname
  1434. this.requestParam.parammaps.feedcode = this.relation.temp.feedcode
  1435. this.requestParam.parammaps.price = row.price
  1436. this.requestParam.parammaps.remark = row.remark
  1437. this.requestParam.parammaps.dry = row.dry
  1438. this.requestParam.parammaps.starch = row.starch
  1439. this.requestParam.parammaps.cp = row.cp
  1440. this.requestParam.parammaps.ca = row.ca
  1441. this.requestParam.parammaps.p = row.p
  1442. this.requestParam.parammaps.n = row.n
  1443. this.requestParam.parammaps.fat = row.fat
  1444. this.requestParam.parammaps.adf = row.adf
  1445. this.requestParam.parammaps.ndf = row.ndf
  1446. this.requestParam.parammaps.ndip = row.ndip
  1447. this.requestParam.parammaps.ash = row.ash
  1448. this.requestParam.parammaps.fpercent = row.fpercent
  1449. this.requestParam.parammaps.iscu = row.iscu
  1450. this.requestParam.parammaps.feednurid = row.id
  1451. PostDataByName(this.requestParam).then(response => {
  1452. console.log('关联保存发送参数', this.requestParam)
  1453. if (response.msg !== 'fail') {
  1454. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1455. this.getRelationList()
  1456. this.getList()
  1457. } else {
  1458. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1459. }
  1460. })
  1461. }).catch(() => {
  1462. this.$message({ type: 'info', message: '已取消' })
  1463. })
  1464. },
  1465. // 营养价值
  1466. handleNutritive(row) {
  1467. console.log('点击了营养价值', row)
  1468. this.dialogFull = false
  1469. this.nutritive.dialogStatus = 'nutritive'
  1470. this.nutritive.dialogFormVisible = true
  1471. this.nutritive.temp = Object.assign({}, row)
  1472. },
  1473. nutritiveData() {
  1474. console.log('点击了营养价值保存')
  1475. this.isokDisable = true
  1476. setTimeout(() => {
  1477. this.isokDisable = false
  1478. }, 1000)
  1479. if (this.nutritive.temp.dry == undefined) { this.$set(this.nutritive.temp, 'dry', '') }
  1480. if (this.nutritive.temp.starch == undefined) { this.$set(this.nutritive.temp, 'starch', '') }
  1481. if (this.nutritive.temp.cp == undefined) { this.$set(this.nutritive.temp, 'cp', '') }
  1482. if (this.nutritive.temp.ca == undefined) { this.$set(this.nutritive.temp, 'ca', '') }
  1483. if (this.nutritive.temp.p == undefined) { this.$set(this.nutritive.temp, 'p', '') }
  1484. if (this.nutritive.temp.n == undefined) { this.$set(this.nutritive.temp, 'n', '') }
  1485. if (this.nutritive.temp.fat == undefined) { this.$set(this.nutritive.temp, 'fat', '') }
  1486. if (this.nutritive.temp.adf == undefined) { this.$set(this.nutritive.temp, 'adf', '') }
  1487. if (this.nutritive.temp.ndf == undefined) { this.$set(this.nutritive.temp, 'ndf', '') }
  1488. if (this.nutritive.temp.ndip == undefined) { this.$set(this.nutritive.temp, 'ndip', '') }
  1489. if (this.nutritive.temp.ash == undefined) { this.$set(this.nutritive.temp, 'ash', '') }
  1490. var positiveNumber = /^\d+(\.\d{1,2})?$/
  1491. if (this.nutritive.temp.dry !== '') {
  1492. if (!positiveNumber.test(parseFloat(this.nutritive.temp.dry))) {
  1493. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1494. return false
  1495. }
  1496. }
  1497. console.log(this.nutritive.temp.starch)
  1498. if (this.nutritive.temp.starch !== '') {
  1499. if (!positiveNumber.test(parseFloat(this.nutritive.temp.starch))) {
  1500. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1501. return false
  1502. }
  1503. }
  1504. if (this.nutritive.temp.cp !== '') {
  1505. if (!positiveNumber.test(parseFloat(this.nutritive.temp.cp))) {
  1506. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1507. return false
  1508. }
  1509. }
  1510. if (this.nutritive.temp.ca !== '') {
  1511. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ca))) {
  1512. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1513. return false
  1514. }
  1515. }
  1516. if (this.nutritive.temp.p !== '') {
  1517. if (!positiveNumber.test(parseFloat(this.nutritive.temp.p))) {
  1518. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1519. return false
  1520. }
  1521. }
  1522. if (this.nutritive.temp.n !== '') {
  1523. if (!positiveNumber.test(parseFloat(this.nutritive.temp.n))) {
  1524. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1525. return false
  1526. }
  1527. }
  1528. if (this.nutritive.temp.fat !== '') {
  1529. if (!positiveNumber.test(parseFloat(this.nutritive.temp.fat))) {
  1530. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1531. return false
  1532. }
  1533. }
  1534. if (this.nutritive.temp.adf !== '') {
  1535. if (!positiveNumber.test(parseFloat(this.nutritive.temp.adf))) {
  1536. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1537. return false
  1538. }
  1539. }
  1540. if (this.nutritive.temp.ndf !== '') {
  1541. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndf))) {
  1542. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1543. return false
  1544. }
  1545. }
  1546. if (this.nutritive.temp.ndip !== '') {
  1547. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ndip))) {
  1548. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1549. return false
  1550. }
  1551. }
  1552. if (this.nutritive.temp.ash !== '') {
  1553. if (!positiveNumber.test(parseFloat(this.nutritive.temp.ash))) {
  1554. this.$message({ type: 'error', message: '请输入自然数,最多保留俩位小数', duration: 2000 })
  1555. return false
  1556. }
  1557. }
  1558. this.requestParam.name = 'insertFeednur'
  1559. this.requestParam.parammaps = {}
  1560. this.requestParam.parammaps.pastureid = this.nutritive.temp.pastureid
  1561. this.requestParam.parammaps.fid = this.nutritive.temp.id
  1562. this.requestParam.parammaps.fname = this.nutritive.temp.fname
  1563. this.requestParam.parammaps.feedcode = this.nutritive.temp.feedcode
  1564. this.requestParam.parammaps.price = this.nutritive.temp.uprice
  1565. this.requestParam.parammaps.remark = this.nutritive.temp.remark
  1566. this.requestParam.parammaps.dry = this.nutritive.temp.dry
  1567. this.requestParam.parammaps.starch = this.nutritive.temp.starch
  1568. this.requestParam.parammaps.cp = this.nutritive.temp.cp
  1569. this.requestParam.parammaps.ca = this.nutritive.temp.ca
  1570. this.requestParam.parammaps.p = this.nutritive.temp.p
  1571. this.requestParam.parammaps.n = this.nutritive.temp.n
  1572. this.requestParam.parammaps.fat = this.nutritive.temp.fat
  1573. this.requestParam.parammaps.adf = this.nutritive.temp.adf
  1574. this.requestParam.parammaps.ndf = this.nutritive.temp.ndf
  1575. this.requestParam.parammaps.ndip = this.nutritive.temp.ndip
  1576. this.requestParam.parammaps.ash = this.nutritive.temp.ash
  1577. this.requestParam.parammaps.fpercent = this.nutritive.temp.fpercent
  1578. this.requestParam.parammaps.iscu = this.nutritive.temp.iscu
  1579. this.requestParam.parammaps.feednurid = '-1'
  1580. PostDataByName(this.requestParam).then(response => {
  1581. console.log('关联保存发送参数', this.requestParam)
  1582. if (response.msg !== 'fail') {
  1583. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1584. this.getList()
  1585. this.nutritive.dialogFormVisible = false
  1586. } else {
  1587. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1588. }
  1589. })
  1590. },
  1591. // 行内删除
  1592. handleRowDelete(row) {
  1593. console.log('点击了行内删除')
  1594. MessageBox.confirm('是否确认删除此信息?', {
  1595. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1596. }).then(() => {
  1597. this.selectList = []
  1598. this.requestParam = {}
  1599. this.requestParam.common = { 'returnmap': '0' }
  1600. this.requestParam.data = []
  1601. this.requestParam.data[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1602. 'pastureid': row.pastureid,
  1603. 'id': row.id
  1604. }}
  1605. this.requestParam.data[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1606. 'pastureid': row.pastureid,
  1607. 'id': row.id
  1608. }}
  1609. ExecDataByConfig(this.requestParam).then(response => {
  1610. console.log('删除保存发送参数', this.requestParam)
  1611. if (response.msg === 'fail') {
  1612. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1613. } else {
  1614. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1615. this.getList()
  1616. }
  1617. })
  1618. }).catch(() => {
  1619. this.$message({ type: 'info', message: '已取消删除' })
  1620. })
  1621. },
  1622. handleSelectionChange(val) {
  1623. console.log('勾选数据', val)
  1624. this.selectList = val
  1625. },
  1626. // 多项删除
  1627. handleDelete() {
  1628. console.log('点击了删除')
  1629. if (this.selectList.length == 0) {
  1630. this.$message({ type: 'error', message: '请选择饲料表信息', duration: 2000 })
  1631. } else {
  1632. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  1633. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1634. }).then(() => {
  1635. this.requestParam = {}
  1636. this.requestParam.common = { 'returnmap': '0' }
  1637. this.requestParam.data = []
  1638. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1639. this.requestParam.data[0].children = []
  1640. this.requestParam.data[0].children[0] = { 'name': 'checkDeleteFeed', 'type': 'v', 'parammaps': {
  1641. id: '@insertSpotList.id',
  1642. pastureid: '@insertSpotList.pastureid'
  1643. }}
  1644. this.requestParam.data[0].children[1] = { 'name': 'deleteFeed', 'type': 'e', 'parammaps': {
  1645. id: '@insertSpotList.id',
  1646. pastureid: '@insertSpotList.pastureid'
  1647. }}
  1648. ExecDataByConfig(this.requestParam).then(response => {
  1649. console.log('删除保存发送参数', this.requestParam)
  1650. if (response.msg === 'fail') {
  1651. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1652. } else {
  1653. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1654. this.getList()
  1655. }
  1656. })
  1657. })
  1658. }
  1659. },
  1660. handleChangeOrder() {
  1661. this.isOrder = false
  1662. this.rowDrop()
  1663. },
  1664. saveChangeOrder() {
  1665. // 保存顺序
  1666. var sortArr = []
  1667. for (let i = 0; i < this.table.list.length; i++) {
  1668. var obj = {}
  1669. obj.sort = i + 1
  1670. obj.id = this.table.list[i].id
  1671. obj.pastureid = this.table.list[i].pastureid
  1672. sortArr.push(obj)
  1673. }
  1674. this.requestParam = {}
  1675. this.requestParam.common = { 'returnmap': '0' }
  1676. this.requestParam.data = []
  1677. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': sortArr }}
  1678. this.requestParam.data[0].children = []
  1679. this.requestParam.data[0].children[0] = { 'name': 'updateFeedSort', 'type': 'e', 'parammaps': {
  1680. id: '@insertSpotList.id',
  1681. pastureid: '@insertSpotList.pastureid',
  1682. sort: '@insertSpotList.sort'
  1683. }}
  1684. ExecDataByConfig(this.requestParam).then(response => {
  1685. console.log('顺序切换保存发送参数', this.requestParam)
  1686. if (response.msg === 'fail') {
  1687. this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1688. } else {
  1689. this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1690. this.getList()
  1691. this.isOrder = true
  1692. }
  1693. })
  1694. },
  1695. cancelChangeOrder() {
  1696. // 取消顺序
  1697. this.getList()
  1698. this.isOrder = true
  1699. },
  1700. // 行拖拽
  1701. rowDrop() {
  1702. console.log(document.querySelector('#table .el-table__body-wrapper tbody'))
  1703. const tbody = document.querySelector('#table .el-table__body-wrapper tbody')
  1704. const that = this
  1705. var sortable = Sortable.create(tbody, {
  1706. disabled: that.dropState,
  1707. onChoose({ newIndex, oldIndex }) {
  1708. if (that.dropState == true) {
  1709. sortable.destroy()
  1710. }
  1711. },
  1712. onEnd({ newIndex, oldIndex }) {
  1713. const currRow = that.table.list.splice(oldIndex, 1)[0]
  1714. that.table.list.splice(newIndex, 0, currRow)
  1715. console.log('索引', newIndex)
  1716. console.log('拖动数据', currRow)
  1717. console.log('上', that.table.list[newIndex - 1])
  1718. console.log('下', that.table.list[newIndex + 1])
  1719. }
  1720. })
  1721. },
  1722. }
  1723. }
  1724. </script>
  1725. <style lang="scss" scoped>
  1726. .search{margin-top:10px;}
  1727. $width:350px;
  1728. $left:325px;
  1729. .selectInput{
  1730. position: relative;
  1731. display: inline-block;
  1732. .Input{width: $width;position: relative;}
  1733. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1734. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  1735. .selectUl{
  1736. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  1737. li{
  1738. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  1739. a{float:left;width: 80px;}
  1740. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  1741. }
  1742. }
  1743. }
  1744. </style>