index.vue 79 KB

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